/* =============================================
   Society Management System - Main Styles
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

:root {
    --primary: #1a3c5e;
    --primary-light: #2563a8;
    --accent: #f97316;
    --accent-light: #fed7aa;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --sidebar-bg: #0f2642;
    --sidebar-text: #94b4d1;
    --sidebar-active: #ffffff;
    --sidebar-active-bg: #1a3c5e;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg: 0 8px 32px rgba(0,0,0,.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Plus Jakarta Sans', sans-serif;
    --mono: 'DM Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
}

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    height: 100vh;
    overflow: hidden;
    position: fixed;
    top: 0; left: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform .3s ease;
}

.sidebar-brand {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.sidebar-brand .brand-icon {
    width: 30px; height: 30px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
}

.sidebar-brand .brand-text h5 {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.sidebar-brand .brand-text small {
    color: var(--sidebar-text);
    font-size: 10px;
}

.sidebar-nav {
    padding: 10px 12px;
    flex: 1;
    overflow-y: auto;
    min-height: 0; /* critical: allows flex child to scroll without pushing footer */
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(148, 180, 209, .5);
    padding: 5px 8px 3px;
}

.sidebar-nav .mt-2 {
    margin-top: 4px !important;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 1px;
    transition: all .2s ease;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.07);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--primary-light);
    color: var(--sidebar-active);
}

.sidebar-nav .nav-link .nav-icon {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
}

/* Sidebar nav badge */
.sidebar-badge {
    margin-left: auto;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

/* ---- Main Layout ---- */
.main-content {
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 0 var(--border);
}

.topbar-left h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-left .breadcrumb-text {
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 12px;
    border-radius: 30px;
    background: var(--bg);
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    transition: background .2s;
}
.topbar-user:hover { background: var(--border); color: var(--text-primary); }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.content-area {
    padding: 28px 24px;
    flex: 1;
}

/* ---- Cards ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: transparent;
}

.card-header h6 {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body { padding: 20px; }

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-icon.red    { background: #fee2e2; color: #dc2626; }

.stat-info h3 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-info p {
    font-size: 12.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ---- Notice Cards ---- */
.notice-card {
    border-left: 4px solid var(--primary);
    background: var(--card-bg);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    transition: transform .2s;
}
.notice-card:hover { transform: translateX(4px); }
.notice-card.urgent { border-left-color: var(--danger); }
.notice-card.high   { border-left-color: var(--warning); }
.notice-card.normal { border-left-color: var(--primary-light); }
.notice-card.low    { border-left-color: #94a3b8; }

.notice-card h6 {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 6px;
}

/* ---- QR Payment Section ---- */
.qr-container {
    background: linear-gradient(135deg, var(--primary) 0%, #1e4d8c 100%);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
    color: #fff;
}

.qr-box {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    display: inline-block;
    margin: 20px 0;
    box-shadow: var(--shadow-lg);
}

.qr-box img {
    display: block;
    width: 220px; height: 220px;
}

/* ---- Tables ---- */
.table {
    font-size: 13.5px;
}

.table th {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    padding: 10px 14px;
}

.table td {
    padding: 12px 14px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.table tbody tr:hover { background: #f8fafc; }

/* ---- Ledger ---- */
.ledger-credit { color: var(--success); font-weight: 600; font-family: var(--mono); }
.ledger-debit  { color: var(--danger); font-weight: 600; font-family: var(--mono); }
.ledger-balance { font-weight: 700; font-family: var(--mono); }

/* ---- Buttons ---- */
.btn {
    font-size: 13px;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    transition: all .2s;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }

.btn-accent {
    background: var(--accent);
    color: #fff;
    border: none;
}
.btn-accent:hover { background: #ea6c0a; color: #fff; }

/* ---- Forms ---- */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 13.5px;
    padding: 9px 14px;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(37, 99, 168, .15);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

/* ---- Badge ---- */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 6px;
}

/* ---- Login Page ---- */
.login-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, #0f2642 0%, #1a3c5e 50%, #1e4d8c 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0,0,0,.25);
}

.login-card .login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo .logo-icon {
    width: 72px; height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 32px;
    margin: 0 auto 16px;
    color: #fff;
}

.login-logo h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 992px) {
    .sidebar { transform: translateX(-260px); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .menu-toggle { display: flex !important; }
}

.menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
}

/* ---- Utilities ---- */
.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 24px;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 24px 0;
}

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }

/* Month pill */
.month-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* =============================================
   Mobile Responsive Improvements
   ============================================= */

/* Sidebar overlay for mobile */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1050;
        width: 260px;
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 1040;
    }
    .sidebar-overlay.show { display: block; }
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }
    .topbar { padding: 0 12px; }
    .content-area { padding: 16px 12px; }
    .page-title { font-size: 20px !important; }
    .page-subtitle { font-size: 13px; }
    .menu-toggle { display: flex !important; }

    /* Stack stat cards in 2 columns on mobile */
    .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }

    /* Table cards scroll on mobile */
    .table-responsive { font-size: 13px; }

    /* Nav tabs scroll on small screens */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; padding-bottom: 2px; }
    .nav-tabs .nav-link { padding: 8px 14px; font-size: 13px; }

    /* Card padding reduce */
    .card-body { padding: 14px; }
    .card-header { padding: 12px 14px; }

    /* Modal full width on mobile */
    .modal-dialog { margin: 8px; }

    /* Topbar user text hidden on very small */
    .topbar-user span { display: none; }
    .topbar-right .month-pill { font-size: 11px; padding: 4px 8px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr !important; }
    .btn { font-size: 13px; }
    h2.page-title { font-size: 18px !important; }
}

/* =============================================
   Invoice Styles (within main layout)
   ============================================= */
.invoice-link {
    display: inline-flex; align-items: center; gap: 5px;
    color: var(--primary-light); font-size: 12px; font-weight: 600;
    text-decoration: none; padding: 4px 10px;
    border: 1px solid var(--primary-light); border-radius: 20px;
    transition: .15s;
}
.invoice-link:hover { background: var(--primary-light); color: #fff; }

/* =============================================
   Complaints Page Styles
   ============================================= */
.complaint-card {
    border-radius: var(--radius);
    transition: box-shadow .2s;
}
.complaint-card:hover { box-shadow: var(--shadow-lg); }

.status-badge-open     { background: #fef9c3; color: #854d0e; }
.status-badge-progress { background: #dbeafe; color: #1e40af; }
.status-badge-resolved { background: #dcfce7; color: #166534; }
.status-badge-closed   { background: #f1f5f9; color: #475569; }

.admin-reply {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #86efac;
    border-radius: 8px;
    padding: 12px 16px;
    margin-top: 10px;
}

/* =============================================
   Sidebar JS helper class
   ============================================= */
/* Ensure menu-toggle always shown on desktop */
@media (min-width: 769px) {
    .menu-toggle { display: none; }
    .main-content { margin-left: 260px; }
    .sidebar { transform: translateX(0) !important; }
}