/* =====================================================
   Main Application Styles
   ===================================================== */

:root {
    --primary-color: #0d47a1;
    --primary-light: #1565c0;
    --primary-dark: #0a3578;
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f36;
}

/* Sidebar */
.sidebar {
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    min-height: 100vh;
    background: var(--sidebar-bg) !important;
    transition: all 0.3s;
    overflow-y: auto;
    overflow-x: hidden;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
}

.sidebar .sidebar-header h5 {
    font-size: 1rem;
    font-weight: 600;
}

.sidebar .sidebar-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: var(--sidebar-bg);
}

.sidebar-nav {
    padding-bottom: 2rem;
}

/* Page Content Wrapper */
#wrapper {
    display: flex;
    min-height: 100vh;
}

#page-content-wrapper {
    margin-left: var(--sidebar-width);
    transition: all 0.3s;
    min-height: 100vh;
    background: #f4f6f9;
}

/* Sidebar collapsed */
.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

#page-content-wrapper.full-width {
    margin-left: 0;
}

/* Fixed topbar */
#page-content-wrapper > .navbar {
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* Dashboard Cards */
.stat-card {
    border: none;
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
}

.stat-card .card-body {
    padding: 1.25rem;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1f36;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: .8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Tables */
.table-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.table-card .card-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 1rem 1.25rem;
}

.table-responsive {
    border-radius: 0 0 12px 12px;
}

.table th {
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .3px;
    color: #6c757d;
    font-weight: 600;
    border-bottom-width: 1px;
}

/* Badges */
.badge-overdue { background: #dc3545; }
.badge-due-soon { background: #ffc107; color: #000; }
.badge-current { background: #198754; }
.badge-orange { background: #fd7e14; }

.badge-type {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    padding: .4em .7em;
    border-radius: .45rem;
    white-space: nowrap;
}

.badge-type.bg-deposit {
    background: #15803d;
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}

.badge-type.bg-withdraw {
    background: #facc15;
    color: #422006;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}

/* Member Profile */
.profile-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.profile-header .avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,.3);
    object-fit: cover;
}

/* Summary Cards */
.summary-card {
    border-left: 4px solid;
    border-radius: 8px;
    transition: transform 0.2s;
}

.summary-card:hover {
    transform: translateY(-1px);
}

/* Loan Statement */
.statement-table th {
    background: #f8f9fa;
}

/* Print Styles */
.print-doc-header {
    display: none;
}

@media print {
    @page {
        size: A4;
        margin: 14mm 12mm 16mm 12mm;
    }
    .sidebar, .navbar, #sidebarToggle, .no-print, .btn, .pagination {
        display: none !important;
    }
    #page-content-wrapper {
        margin-left: 0 !important;
    }
    .container-fluid {
        padding: 0 !important;
    }
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }
    .stat-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
    table {
        font-size: 10pt;
    }
    a {
        text-decoration: none;
        color: #000;
    }

    /* Printable report document header */
    .print-doc-header {
        display: block !important;
        margin-bottom: 14px;
    }
    .print-doc-header .pdh-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 0;
    }
    .print-doc-header .pdh-table td {
        border: none !important;
        padding: 0 !important;
        vertical-align: top;
        background: none !important;
        font-size: 10pt;
    }
    .print-doc-header .pdh-logo-cell {
        width: 70px;
        padding-right: 12px !important;
    }
    .print-doc-header .pdh-logo-cell img {
        max-height: 60px;
        max-width: 64px;
        object-fit: contain;
    }
    .print-doc-header .pdh-club-name {
        font-size: 17pt;
        font-weight: 700;
        color: #12294d;
        letter-spacing: .3px;
        line-height: 1.15;
    }
    .print-doc-header .pdh-club-line {
        font-size: 9pt;
        color: #333;
        line-height: 1.35;
    }
    .print-doc-header .pdh-doc-cell {
        text-align: right;
        white-space: nowrap;
        padding-left: 12px !important;
    }
    .print-doc-header .pdh-doc-type {
        font-size: 9pt;
        font-weight: 700;
        letter-spacing: 1px;
        color: #12294d;
    }
    .print-doc-header .pdh-doc-date {
        font-size: 8.5pt;
        color: #555;
    }
    .print-doc-header .pdh-rule {
        border-top: 2.5px solid #12294d;
        margin: 8px 0 12px;
    }
    .print-doc-header .pdh-report-title {
        text-align: center;
        font-size: 14pt;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .6px;
        color: #000;
    }
    .print-doc-header .pdh-report-sub {
        text-align: center;
        font-size: 10pt;
        color: #333;
        margin-top: 2px;
    }
    .print-doc-header .pdh-report-meta {
        text-align: center;
        font-size: 8.5pt;
        color: #555;
        margin-top: 4px;
    }
    .print-doc-header .pdh-report-meta span + span::before {
        content: "  \2022  ";
    }

    /* Professional data tables */
    .table-responsive {
        overflow: visible !important;
    }
    .table-card {
        border: none !important;
        box-shadow: none !important;
    }
    .card {
        box-shadow: none !important;
    }
    .print-doc-header ~ .card .card-header,
    .print-doc-header ~ * .card-header {
        display: none !important;
    }
    table.table {
        width: 100% !important;
        border-collapse: collapse !important;
        margin-bottom: 0 !important;
    }
    table.table > thead > tr > th {
        background: #e9edf3 !important;
        color: #000 !important;
        border: 1px solid #9aa6b4 !important;
        padding: 6px 8px !important;
        text-align: left;
        font-weight: 700;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    table.table > tbody > tr > td {
        border: 1px solid #cfd6de !important;
        padding: 5px 8px !important;
        color: #000 !important;
    }
    table.table > tbody > tr:nth-child(even) > td {
        background: #f6f8fa !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    table.table thead {
        display: table-header-group;
    }
    table.table tr {
        page-break-inside: avoid;
    }
    .badge {
        background: #fff !important;
        color: #000 !important;
        border: 1px solid #8a949e !important;
        font-weight: 600;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    .print-doc-header .pdh-family,
    .print-only {
        display: block !important;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: .5;
}

.empty-state h5 {
    color: #495057;
    margin-bottom: .5rem;
}

/* Receipt */
.receipt-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 2rem;
    border: 2px dashed #ccc;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
}

.receipt-container .receipt-header {
    text-align: center;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.receipt-container .receipt-footer {
    text-align: center;
    border-top: 1px dashed #ccc;
    padding-top: 1rem;
    margin-top: 1rem;
    font-size: .85rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        margin-left: calc(-1 * var(--sidebar-width));
        height: 100vh;
        min-height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .sidebar.show {
        margin-left: 0;
    }
    #page-content-wrapper {
        margin-left: 0 !important;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,.5);
        z-index: 999;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

@media (max-width: 575.98px) {
    .stat-card .stat-value {
        font-size: 1.2rem;
    }
    .container-fluid {
        padding: .75rem !important;
    }
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Brand panel */
.login-brand {
    flex: 1 1 45%;
    max-width: 45%;
    background: linear-gradient(160deg, #081f4d 0%, #0d47a1 55%, #1565c0 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3.25rem 4rem;
    position: relative;
    overflow: hidden;
}

.login-brand::before,
.login-brand::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    animation: loginFloat 12s ease-in-out infinite;
}

.login-brand::before {
    width: 420px;
    height: 420px;
    top: -140px;
    right: -120px;
}

.login-brand::after {
    width: 560px;
    height: 560px;
    bottom: -220px;
    left: -160px;
    animation-delay: -6s;
}

@keyframes loginFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -20px) scale(1.08); }
}

.login-brand > * {
    position: relative;
    z-index: 1;
}

.login-brand .brand-badge {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: .45rem .9rem;
    border-radius: 999px;
    font-size: .78rem;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.login-brand h2 {
    font-weight: 700;
    line-height: 1.2;
}

.login-brand .lead {
    color: rgba(255, 255, 255, 0.85);
    font-size: 1.05rem;
    max-width: 34rem;
}

.login-features {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0 0;
    display: grid;
    gap: 1rem;
}

.login-features li {
    display: flex;
    align-items: center;
    gap: .85rem;
    font-size: .95rem;
    color: rgba(255, 255, 255, 0.92);
}

.login-features .feat-icon {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: .7rem;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.login-brand .brand-footer {
    color: rgba(255, 255, 255, 0.55);
    font-size: .8rem;
}

/* Form panel */
.login-form-wrap {
    flex: 1 1 55%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f4f6fb;
    padding: 2.5rem 2rem;
    position: relative;
}

.login-card {
    width: 100%;
    max-width: 408px;
    border: none;
    border-radius: 1.1rem;
    box-shadow: 0 12px 48px rgba(13, 71, 161, 0.12);
    animation: loginCardIn .45s ease-out both;
}

@keyframes loginCardIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-card .card-body {
    padding: 2.5rem;
}

.login-card .welcome-title {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: .25rem;
}

.login-card .welcome-sub {
    color: #6b7280;
    font-size: .9rem;
    margin-bottom: 1.75rem;
}

.login-card .form-floating > .form-control {
    padding-left: 2.75rem;
}

.login-card .input-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa3b2;
    font-size: 1rem;
    z-index: 5;
    pointer-events: none;
}

.login-card .password-toggle {
    position: absolute;
    right: .35rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    border: none;
    background: transparent;
    color: #9aa3b2;
    padding: .45rem .6rem;
    line-height: 1;
}

.login-card .password-toggle:hover { color: var(--primary-color); }

.login-card .btn-signin {
    --bs-btn-bg: var(--primary-color);
    --bs-btn-border-color: var(--primary-color);
    --bs-btn-hover-bg: #0a3578;
    --bs-btn-hover-border-color: #0a3578;
    border-radius: .7rem;
    font-weight: 600;
    padding: .8rem 1rem;
    letter-spacing: .015em;
}

.login-card .form-check-label,
.login-card .forgot-link {
    font-size: .85rem;
}

.login-form-wrap .login-copyright {
    position: absolute;
    bottom: 1.5rem;
    color: #99a1b3;
    font-size: .78rem;
}

.login-back {
    position: absolute;
    top: 1.25rem;
    left: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .86rem;
    font-weight: 500;
    color: #5a6472;
    text-decoration: none;
    transition: color .15s ease;
}
.login-back:hover { color: var(--primary-color); }

.login-form-wrap .input-group-text {
    background: #f4f6fb;
    border-right: 0;
    color: #9aa3b2;
}

@media (max-width: 991.98px) {
    .login-brand { display: none; }
    .login-form-wrap { flex: 1 1 100%; background: linear-gradient(160deg, #081f4d 0%, #0d47a1 100%); }
    .login-card { background: #fff; }
    .login-form-wrap .login-copyright { color: rgba(255, 255, 255, 0.6); }
    .login-back { color: rgba(255, 255, 255, 0.85); }
    .login-back:hover { color: #ffffff; }
    .login-page { overflow-y: auto; }
}

/* Notification bell */
.notification-badge {
    position: relative;
}

.notification-badge .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: .6rem;
    padding: 2px 5px;
}

/* Overdue indicator pulse */
.pulse-danger {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: .5; }
    100% { opacity: 1; }
}

/* Filter form */
.filter-form {
    background: #fff;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

/* Nav tabs for member profile */
.profile-tabs .nav-link {
    font-size: .9rem;
}
.profile-tabs .nav-link.active {
    font-weight: 600;
}

/* Breakdown table */
.breakdown-table td:last-child {
    text-align: right;
    font-weight: 500;
}

.breakdown-table tr.total td {
    font-weight: 700;
    border-top: 2px solid #dee2e6;
    font-size: 1.05rem;
}
