/* ============================================
   Society Maintenance Management System
   Light Professional Theme
   ============================================ */

/* ---- DESIGN TOKENS ---- */
:root {
    --primary:       #1d4ed8;
    --primary-dark:  #1e3a8a;
    --primary-light: #dbeafe;
    --success:       #059669;
    --success-light: #d1fae5;
    --warning:       #d97706;
    --warning-light: #fef3c7;
    --danger:        #dc2626;
    --danger-light:  #fee2e2;
    --gray-50:       #f8fafc;
    --gray-100:      #f1f5f9;
    --gray-200:      #e2e8f0;
    --gray-300:      #cbd5e1;
    --gray-400:      #94a3b8;
    --gray-500:      #64748b;
    --gray-600:      #475569;
    --gray-700:      #334155;
    --gray-800:      #1e293b;
    --gray-900:      #0f172a;
    --white:         #ffffff;
    --shadow-sm:     0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow:        0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md:     0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg:     0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius:        0.5rem;
    --radius-lg:     0.75rem;
    --font:          'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --touch-min:     44px;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Fluid media */
img, video { max-width: 100%; height: auto; }

html { font-size: 16px; overflow-x: hidden; }
body { overflow-x: hidden; }

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover,
a:focus-visible { text-decoration: underline; }

/* ---- LAYOUT ---- */
.layout { display: flex; min-height: 100vh; }

/* ---- SIDEBAR ---- */
.sidebar {
    width: 260px;
    background: var(--white);
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.brand-name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.3;
}

.brand-sub {
    font-size: 0.7rem;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.2rem;
}

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }

.nav-section-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.75rem 1.25rem 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.25rem;
    min-height: var(--touch-min);
    color: var(--gray-600);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    position: relative;
}

.nav-item:hover,
.nav-item:focus-visible {
    background: var(--gray-50);
    color: var(--primary);
    text-decoration: none;
    outline: none;
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    font-size: 0.8rem;
    color: var(--gray-500);
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--touch-min);
    color: var(--danger);
    font-weight: 500;
}

.sidebar-footer a:hover,
.sidebar-footer a:focus-visible { text-decoration: underline; outline: none; }

/* ---- MAIN CONTENT ---- */
.main { margin-left: 260px; flex: 1; display: flex; flex-direction: column; }

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0.875rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

/* ---- HAMBURGER ---- */
.hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--gray-600);
    border-radius: var(--radius);
    flex-shrink: 0;
}
.hamburger:hover,
.hamburger:focus-visible { background: var(--gray-100); outline: none; }
.hamburger svg { width: 22px; height: 22px; }

/* ---- SIDEBAR OVERLAY ---- */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgb(0 0 0 / 0.45);
    z-index: 99;
    cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* ---- RESPONSIVE GRID UTILITIES ---- */
.grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: start;
}

.grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.topbar-title { font-size: 1.125rem; font-weight: 600; color: var(--gray-800); }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: var(--gray-600);
}

.avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    flex-shrink: 0;
}

.page-content {
    padding: 2rem;
    flex: 1;
    container-type: inline-size;
}

/* ---- AUTH PAGES ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 1.5rem;
}

.auth-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 1.75rem 2.5rem;
    width: 100%;
    max-width: 420px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.25rem;
}

/* Flattened from .auth-logo .logo-icon */
.logo-icon {
    width: 44px; height: 44px;
    background: var(--primary-light);
    border-radius: var(--radius-lg);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 0.6rem;
}

.logo-icon svg { width: 22px; height: 22px; color: var(--primary); }

.auth-logo h1 { font-size: 1.2rem; font-weight: 700; color: var(--gray-800); }
.auth-logo p  { font-size: 0.82rem; color: var(--gray-500); margin-top: 0.2rem; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1.25rem; }

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="tel"],
select,
textarea {
    width: 100%;
    min-height: var(--touch-min);
    padding: 0.65rem 0.875rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font);
    outline: none;
}

input:focus,
input:focus-visible,
select:focus,
select:focus-visible,
textarea:focus,
textarea:focus-visible {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgb(29 78 216 / 0.1);
}

textarea { resize: vertical; min-height: 80px; }

select { cursor: pointer; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    min-height: var(--touch-min);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
    white-space: nowrap;
    font-family: var(--font);
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Shared: colour buttons keep white text on hover/focus */
.btn-primary  { background: var(--primary);  color: var(--white); border-color: var(--primary); }
.btn-success  { background: var(--success);  color: var(--white); border-color: var(--success); }
.btn-danger   { background: var(--danger);   color: var(--white); border-color: var(--danger); }
.btn-warning  { background: var(--warning);  color: var(--white); border-color: var(--warning); }
.btn-whatsapp { background: #25d366;         color: var(--white); border-color: #25d366; }

.btn-primary:hover,  .btn-primary:focus-visible  { background: var(--primary-dark); border-color: var(--primary-dark); color: var(--white); }
.btn-success:hover,  .btn-success:focus-visible  { background: #047857; color: var(--white); }
.btn-danger:hover,   .btn-danger:focus-visible   { background: #b91c1c; color: var(--white); }
.btn-warning:hover,  .btn-warning:focus-visible  { background: #b45309; color: var(--white); }
.btn-whatsapp:hover, .btn-whatsapp:focus-visible { background: #1da851; color: var(--white); }

.btn-outline { background: transparent; color: var(--gray-600); border-color: var(--gray-300); }
.btn-outline:hover,
.btn-outline:focus-visible { background: var(--gray-50); }

/* Remove default focus ring — we handle it via border/box-shadow */
.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    text-decoration: none;
}

.btn-sm   { padding: 0.4rem 0.875rem; font-size: 0.8rem; min-height: var(--touch-min); }
.btn-lg   { padding: 0.8rem 1.75rem;  font-size: 1rem; }
.btn-full { width: 100%; }

/* ---- CARDS ---- */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.card-title    { font-size: 1rem;  font-weight: 600; color: var(--gray-800); }
.card-subtitle { font-size: 0.8rem; color: var(--gray-500); margin-top: 0.15rem; }

.card-body { padding: 1.5rem; }

/* ---- STATS GRID ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.blue   { background: var(--primary-light); color: var(--primary); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.yellow { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light);  color: var(--danger); }

/* Flattened: was .stat-info .stat-label / .wa-details .wa-label — identical rules merged */
.stat-label,
.wa-label {
    font-size: 0.75rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Flattened: was .stat-info .stat-value */
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--gray-800); line-height: 1.2; margin-top: 0.2rem; }

/* Flattened: was .wa-details .wa-number */
.wa-number { font-size: 1.25rem; font-weight: 700; color: var(--gray-800); }

/* ---- TABLE ---- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

thead th {
    background: var(--gray-50);
    color: var(--gray-500);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

tbody td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td      { background: var(--gray-50); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Pending uses darker amber (#92400e) for WCAG AA contrast on warning-light */
.badge-pending  { background: var(--warning-light); color: #92400e; }
.badge-approved { background: var(--success-light); color: var(--success); }
.badge-rejected { background: var(--danger-light);  color: var(--danger); }
.badge-reversed { background: var(--gray-100);      color: var(--gray-500); }
.badge-active   { background: var(--success-light); color: var(--success); }
.badge-inactive { background: var(--gray-100);      color: var(--gray-500); }

/* ---- ALERTS ---- */
.alert {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border: 1px solid transparent;
}
.alert svg      { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success  { background: var(--success-light); color: #065f46; border-color: #6ee7b7; }
.alert-danger   { background: var(--danger-light);  color: #991b1b; border-color: #fca5a5; }
.alert-warning  { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.alert-info     { background: var(--primary-light); color: #1e3a8a; border-color: #93c5fd; }

/* ---- PAYMENT MESSAGE BOX ---- */
.message-preview {
    background: #e7f8ee;
    border: 1.5px solid #25d366;
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    font-size: 0.875rem;
    line-height: 1.8;
    color: var(--gray-800);
    font-family: monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.whatsapp-number-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
}

.wa-icon     { color: #25d366; flex-shrink: 0; }
.wa-icon svg { width: 36px; height: 36px; }

/* ---- DIVIDER ---- */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 1.5rem 0; }

/* ---- MODAL ---- */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgb(0 0 0 / 0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }

.modal-close {
    /* Touch target: 44×44 with visual size of 28×28 via padding */
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent;
    color: var(--gray-400); cursor: pointer;
    border-radius: 50%;
    transition: background 0.15s, color 0.15s;
    margin: -0.5rem -0.5rem -0.5rem 0;
}
.modal-close:hover,
.modal-close:focus-visible {
    background: var(--gray-100);
    color: var(--gray-700);
    outline: none;
}

.modal-body   { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--gray-200); display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ---- CONFIRM DIALOG (replaces native confirm() on destructive/high-impact actions) ---- */
.confirm-icon {
    width: 56px; height: 56px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1rem;
}
.confirm-modal-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}
.confirm-modal-message {
    font-size: 0.875rem;
    color: var(--gray-600);
    line-height: 1.5;
}

/* ---- INFO ROWS ---- */
.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--gray-500); font-weight: 500; }
.info-value { color: var(--gray-800); font-weight: 600; text-align: right; }

/* ---- PAGE HEADER ---- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-title    { font-size: 1.375rem; font-weight: 700; color: var(--gray-800); }
.page-subtitle { font-size: 0.85rem;  color: var(--gray-500); margin-top: 0.2rem; }
.page-actions  { display: flex; gap: 0.75rem; flex-shrink: 0; }

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--gray-500); }
.text-small  { font-size: 0.8rem; }
.fw-bold     { font-weight: 700; }
.d-flex      { display: flex; }
.align-center { align-items: center; }
.flex-wrap   { flex-wrap: wrap; }
.gap-1  { gap: 0.5rem; }
.mt-1   { margin-top: 0.5rem; }
.mt-2   { margin-top: 1rem; }
.mt-3   { margin-top: 1.5rem; }
.mb-1   { margin-bottom: 0.5rem; }
.mb-2   { margin-bottom: 1rem; }
.mb-3   { margin-bottom: 1.5rem; }

.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--gray-400); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 1rem; opacity: 0.5; }
.empty-state p   { font-size: 0.9rem; }

/* ---- CONTAINER QUERIES (component-level responsiveness) ---- */
@container (max-width: 640px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row   { grid-template-columns: 1fr; }
}

@container (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 100;
    }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .page-content { padding: 1.25rem; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; }
    .topbar { padding: 0.75rem 1rem; gap: 0.75rem; }
    .hamburger { display: flex; }
    .grid-sidebar,
    .grid-2col { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card  { padding: 1.75rem 1.25rem; }
    .form-row   { grid-template-columns: 1fr; }
}
