/**
 * NousKaiGnosi CRM - Unified Presentation Stylesheet
 * Version: 2.0.0
 * Bootstrap 5.3+ Extensions, Responsiveness, Modals & Touch UX
 */

/* ==========================================================================
   1. CSS Variables & Global Typography
   ========================================================================== */
:root {
    --crm-font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --crm-bg: #f4f6f9;
    --crm-sidebar-bg: #1e293b;
    --crm-sidebar-hover: #334155;
    --crm-sidebar-text: #94a3b8;
    --crm-sidebar-link: #cbd5e1;
    --crm-card-radius: 0.75rem;
    --crm-touch-target: 44px;
}

body {
    font-family: var(--crm-font);
    background-color: var(--crm-bg);
    min-height: 100vh;
    color: #1e293b;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   2. Layout & Shell Structure
   ========================================================================== */
.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.5px;
}

.main-content {
    padding: 1rem;
    min-width: 0;
    transition: padding 0.2s ease-in-out;
}

@media (min-width: 768px) {
    .main-content {
        padding: 1.5rem;
    }
}

/* ==========================================================================
   3. Sidebar Navigation (Desktop & Mobile Offcanvas)
   ========================================================================== */
.sidebar {
    min-height: calc(100vh - 56px);
    background-color: var(--crm-sidebar-bg);
    color: var(--crm-sidebar-text);
    font-size: 0.85rem;
}

.sidebar-compact {
    padding: 0.35rem 0;
}

.sidebar-section + .sidebar-section {
    margin-top: 0.5rem;
}

.sidebar-heading {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 0.7rem 1rem 0.35rem;
    font-weight: 700;
}

.sidebar .nav-link {
    color: var(--crm-sidebar-link);
    padding: 0.65rem 0.9rem;
    border-radius: 0.45rem;
    margin: 0.1rem 0.5rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-height: var(--crm-touch-target);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
    line-height: 1.25;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: #ffffff;
    background-color: var(--crm-sidebar-hover);
}

.sidebar .nav-link i {
    width: 18px;
    font-size: 0.85rem;
    text-align: center;
    flex-shrink: 0;
}

.sidebar .nav-link span {
    white-space: nowrap;
}

.offcanvas.sidebar {
    max-width: 300px;
    width: 82vw;
}

.offcanvas.sidebar .offcanvas-header {
    min-height: 56px;
}

/* ==========================================================================
   4. Cards & Dashboard Containers
   ========================================================================== */
.card-dashboard {
    border: none;
    border-radius: var(--crm-card-radius);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: none;
}

.card-dashboard:hover {
    transform: none !important;
}

.parents-table-card {
    transition: none;
}

.parents-table-card:hover {
    transform: none !important;
}

/* Income KPI Cards */
.income-kpi-card {
    border: none;
    border-radius: 0.85rem;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

.income-kpi-value {
    font-size: 1.45rem;
    font-weight: 700;
}

.income-filter-card,
.income-table-card {
    border: none;
    border-radius: 0.85rem;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

/* ==========================================================================
   5. Touch-Friendly Controls & Forms (≥ 44px)
   ========================================================================== */
/* Standard Inputs & Selects */
.form-control,
.form-select {
    min-height: var(--crm-touch-target);
    font-size: 0.95rem;
    border-radius: 0.5rem;
}

.form-control-sm,
.form-select-sm {
    min-height: 38px;
    font-size: 0.875rem;
}

/* Buttons with Touch Target Compliance */
.btn {
    min-height: var(--crm-touch-target);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.15s ease-in-out;
}

/* Small Buttons in Tables / Toolbars with Accessible Touch Area */
.btn-sm {
    min-height: 36px;
    min-width: 36px;
    padding: 0.35rem 0.65rem;
    font-size: 0.85rem;
    border-radius: 0.375rem;
    position: relative;
}

/* Touch Expansion for Icon-only small buttons on touchscreens */
@media (pointer: coarse) {
    .btn-sm {
        min-height: var(--crm-touch-target);
        min-width: var(--crm-touch-target);
        padding: 0.45rem 0.75rem;
    }
}

/* Top Navbar Toggle Button */
.navbar .btn-outline-light {
    min-height: var(--crm-touch-target);
    min-width: var(--crm-touch-target);
    padding: 0.5rem 0.75rem;
}

/* Dropdown items touch accessibility */
.dropdown-item {
    min-height: var(--crm-touch-target);
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Responsive Button Groups on Mobile */
@media (max-width: 575.98px) {
    .btn-group-responsive {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.25rem;
    }
    .btn-group-responsive > .btn {
        border-radius: 0.375rem !important;
        width: 100% !important;
        margin-left: 0 !important;
    }
}

/* Checkboxes and Radios */
.form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.15em;
    cursor: pointer;
}

.form-check-label {
    cursor: pointer;
    user-select: none;
}

/* Custom Select Heights */
.select-h-120 {
    height: 120px;
}

.select-h-180 {
    height: 180px;
}

.exam-filter-input {
    max-width: 280px;
    width: 100%;
}

@media (max-width: 575.98px) {
    .exam-filter-input {
        max-width: 100%;
    }
}

/* ==========================================================================
   6. Tables & Responsive Layouts
   ========================================================================== */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    border-radius: inherit;
    margin-bottom: 0;
}

.table th,
.table td {
    vertical-align: middle;
}

.th-shrink {
    width: 1%;
    white-space: nowrap;
}

.courses-cell {
    white-space: normal;
    word-break: break-word;
}

.income-summary-table {
    table-layout: fixed;
    min-width: 820px;
}

.income-summary-table th,
.income-summary-table td {
    vertical-align: middle;
}

/* Responsive Table Breakdown: Students Table (<= 991.98px) */
@media (max-width: 991.98px) {
    .responsive-student-table thead {
        display: none;
    }
    .responsive-student-table,
    .responsive-student-table tbody,
    .responsive-student-table tr,
    .responsive-student-table td {
        display: block;
        width: 100%;
    }
    .responsive-student-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.65rem;
        padding: 0.85rem;
        background-color: #ffffff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }
    .responsive-student-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.55rem 0;
        border-bottom: 1px dashed #e2e8f0;
        text-align: right;
    }
    .responsive-student-table td:last-child {
        border-bottom: none;
        padding-top: 0.75rem;
    }
    .responsive-student-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #4e73df;
        text-align: left;
        padding-right: 1rem;
        flex-shrink: 0;
    }
    .responsive-student-table .action-buttons {
        justify-content: flex-end;
    }
}

/* Responsive Table Breakdown: Payments Table (<= 767.98px) */
@media (max-width: 767.98px) {
    .payments-table thead {
        display: none;
    }
    .payments-table,
    .payments-table tbody,
    .payments-table tr,
    .payments-table td {
        display: block;
        width: 100%;
    }
    .payments-table tr {
        margin-bottom: 1rem;
        border: 1px solid #e3e6f0;
        border-radius: 0.65rem;
        padding: 0.85rem;
        background-color: #ffffff;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }
    .payments-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.55rem 0;
        border-bottom: 1px dashed #e3e6f0;
        text-align: right;
    }
    .payments-table td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-top: 0.5rem;
    }
    .payments-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #6c757d;
        text-align: left;
        padding-right: 1rem;
        font-size: 0.875rem;
        flex-shrink: 0;
    }
    .payments-table td[data-label="Ενέργειες"] {
        justify-content: flex-end;
    }
    .payments-table td[data-label="Ενέργειες"]::before {
        display: none;
    }
}

/* ==========================================================================
   7. Modals Polish & Form Hygiene
   ========================================================================== */
.modal-content {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
    padding: 1rem 1.25rem;
}

.modal-header .btn-close {
    min-height: var(--crm-touch-target);
    min-width: var(--crm-touch-target);
    padding: 0.75rem;
    margin: -0.5rem -0.5rem -0.5rem auto;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 0.85rem 1.25rem;
}

.modal-footer .btn {
    min-width: 100px;
}

@media (max-width: 575.98px) {
    .modal-dialog {
        margin: 0.5rem;
    }
    .modal-dialog-centered {
        min-height: calc(100% - 1rem);
    }
    .modal-body {
        padding: 1rem;
    }
    .modal-footer {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    .modal-footer .btn {
        width: 100%;
        margin: 0 !important;
    }
}

/* ==========================================================================
   8. Tabs Responsive Scrolling
   ========================================================================== */
.nav-tabs-scrollable,
.student-profile-tabs,
.card-header-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    padding-bottom: 2px;
}

.nav-tabs-scrollable::-webkit-scrollbar,
.student-profile-tabs::-webkit-scrollbar,
.card-header-tabs::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.nav-tabs-scrollable .nav-link,
.student-profile-tabs .nav-link,
.card-header-tabs .nav-link {
    white-space: nowrap;
    min-height: var(--crm-touch-target);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

@media (min-width: 992px) {
    .card-header-tabs {
        flex-wrap: wrap;
        overflow-x: visible;
    }
}

.student-profile-table th {
    white-space: nowrap;
}

.pre-wrap-text {
    white-space: pre-wrap;
    text-align: left;
    word-break: break-word;
}

/* ==========================================================================
   9. Email Dispatch Responsive Layout
   ========================================================================== */
.email-dispatch-layout {
    display: flex;
    flex-wrap: nowrap;
    gap: 1.5rem;
    align-items: flex-start;
    width: 100%;
    min-width: 0;
}

.email-form-col {
    flex: 1 1 auto;
    min-width: 0;
}

@media (max-width: 991.98px) {
    .email-dispatch-layout {
        flex-direction: column;
        flex-wrap: wrap;
    }
    .email-form-col {
        width: 100%;
    }
}

/* ==========================================================================
   10. Wizard Stepper & Enrollment Styles
   ========================================================================== */
.wizard-stepper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin-bottom: 1.5rem;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.wizard-stepper::-webkit-scrollbar {
    display: none;
}

.wizard-stepper::before {
    content: '';
    position: absolute;
    top: 24px;
    left: 40px;
    right: 40px;
    height: 4px;
    background: #e2e8f0;
    z-index: 1;
}

.wizard-step-item {
    position: relative;
    z-index: 2;
    text-align: center;
    flex: 1;
    min-width: 70px;
}

.wizard-step-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #ffffff;
    border: 3px solid #cbd5e1;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: 700;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wizard-step-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
}

.wizard-step-desc {
    font-size: 0.72rem;
    color: #94a3b8;
}

.wizard-step-item.active .wizard-step-circle {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: #ffffff;
    box-shadow: 0 0 0 5px rgba(13, 110, 253, 0.2);
    transform: scale(1.08);
}

.wizard-step-item.active .wizard-step-title {
    color: #0d6efd;
    font-weight: 700;
}

.wizard-step-item.completed .wizard-step-circle {
    background-color: #198754;
    border-color: #198754;
    color: #ffffff;
}

.wizard-step-item.completed .wizard-step-title {
    color: #198754;
}

@media (max-width: 575.98px) {
    .wizard-stepper::before {
        top: 18px;
        left: 25px;
        right: 25px;
        height: 3px;
    }
    .wizard-step-circle {
        width: 36px;
        height: 36px;
        font-size: 0.85rem;
        border-width: 2px;
    }
    .wizard-step-title {
        font-size: 0.72rem;
    }
}

.step-card {
    border-radius: 1rem;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.step-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #ffffff;
    padding: 1.25rem 1.5rem;
}

/* Fullscreen Pure CSS Loading Overlay */
.wizard-loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    z-index: 99999;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.wizard-signature-line {
    border-top: 1px solid #1e293b;
    width: 200px;
    margin-left: auto;
    margin-right: auto;
}

.print-only-header {
    display: none;
}

/* Print Stylesheet */
@media print {
    body {
        background-color: #ffffff !important;
        font-size: 11pt;
        color: #000000 !important;
    }
    .navbar,
    .sidebar,
    .wizard-stepper,
    .wizard-actions,
    .btn,
    .breadcrumb,
    #sidebarOffcanvas,
    .d-print-none,
    #wizardStepperCard,
    .wizard-loading-overlay,
    #wizardLoadingOverlay,
    nav,
    .top-header-nav {
        display: none !important;
    }
    .main-content {
        padding: 0 !important;
        width: 100% !important;
        margin: 0 !important;
    }
    .step-card {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    .step-header {
        display: none !important;
    }
    .card {
        border: 1px solid #dee2e6 !important;
        box-shadow: none !important;
        background-color: #ffffff !important;
    }
    .card.bg-light {
        background-color: #f8f9fa !important;
    }
    .badge {
        border: 1px solid #333 !important;
        color: #000 !important;
        background: transparent !important;
    }
    .table {
        color: #000 !important;
    }
    .table-light {
        background-color: #f1f5f9 !important;
    }
    .print-only-header {
        display: block !important;
    }
}

/* ==========================================================================
   11. Auth Pages Layout (Login, Forgot, Reset)
   ========================================================================== */
.auth-body {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card,
.login-card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    background: #ffffff;
    overflow: hidden;
    width: 100%;
    max-width: 440px;
}

.auth-header,
.login-header {
    background: #1e293b;
    color: #ffffff;
    padding: 2.25rem 2rem 1.75rem;
    text-align: center;
}

.auth-content,
.login-body {
    padding: 2rem;
}

/* ==========================================================================
   12. Utilities & Accessibility Helpers
   ========================================================================== */
.avatar-circle-52 {
    width: 52px;
    height: 52px;
    min-width: 52px;
}

.cursor-pointer {
    cursor: pointer;
}

.max-h-280-scroll {
    max-height: 280px;
    overflow-y: auto;
}

.text-break-word {
    word-break: break-word;
    white-space: normal;
}
