/* ============================================
   TAHSILDAR ERP v2.0 — Design System
   Dark Mode + Glassmorphism + Premium UI
   ============================================ */

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

/* ---------- Design Tokens ---------- */
:root {
    --bg-base: #f4f7f9;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.7);
    --bg-glass-hover: rgba(255, 255, 255, 0.9);
    --border-glass: rgba(0, 0, 0, 0.06);
    --border-subtle: rgba(0, 0, 0, 0.04);
    --border-focus: rgba(0, 204, 255, 0.4);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    --accent: #00d4ff;
    --accent-dark: #0066cc;
    --accent-glow: rgba(0, 212, 255, 0.15);
    --accent-soft: rgba(0, 212, 255, 0.1);
    --success: #10b981;
    --success-soft: rgba(16,185,129,0.12);
    --warning: #f59e0b;
    --warning-soft: rgba(245,158,11,0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239,68,68,0.12);
    --info: #3b82f6;
    --info-soft: rgba(59,130,246,0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 6px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
    --shadow-glow: 0 0 20px rgba(0,212,255,0.2);
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
    --sidebar-width: 270px;
    --topbar-height: 70px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; background: var(--bg-base); scroll-behavior: smooth; }
body {
    min-height: 100vh;
    color: var(--text-primary);
    background: var(--bg-base);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
table { border-collapse: collapse; width: 100%; }

/* ---------- App Shell ---------- */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-glass);
    z-index: 40;
    overflow-y: auto;
    transition: transform var(--transition-base);
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 39;
    opacity: 0;
    transition: opacity var(--transition-base);
}
.sidebar-backdrop.is-open { display: block; opacity: 1; }

/* Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 8px;
    margin-bottom: 28px;
    text-decoration: none;
}
.brand-mark {
    width: 40px; height: 40px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), #0099cc);
    color: var(--text-inverse);
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 18px;
    box-shadow: var(--shadow-glow);
    flex-shrink: 0;
}
.brand strong { display: block; font-size: 15px; font-weight: 700; color: var(--text-primary); }
.brand small { display: block; font-size: 11px; color: var(--text-muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.5px; }

/* Nav */
.nav-menu { display: flex; flex-direction: column; gap: 4px; }
.nav-menu a, .ghost-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 13.5px;
    transition: all var(--transition-fast);
    position: relative;
}
.nav-menu a:hover, .ghost-link:hover {
    color: var(--text-primary);
    background: var(--bg-glass-hover);
}
.nav-menu a.active {
    color: var(--accent);
    background: var(--accent-soft);
}
.nav-menu a.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 20px;
    background: var(--accent);
    border-radius: 0 4px 4px 0;
}
.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* ---------- Main Content ---------- */
.main-content {
    grid-column: 2;
    min-width: 0;
    padding: 28px 32px;
    background: var(--bg-base);
}

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 28px;
}
.topbar h1 {
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}
.eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.hamburger-btn {
    display: none;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
}

/* User Chip */
.user-chip {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    text-align: right;
    backdrop-filter: blur(12px);
    min-width: 180px;
}
.user-chip strong { font-size: 13px; font-weight: 600; }
.user-chip span { font-size: 12px; color: var(--text-secondary); }

/* ---------- Grid System ---------- */
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Glass Cards ---------- */
.panel, .stat-card, .login-box, .taxpayer-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.panel:hover, .taxpayer-card:hover {
    border-color: rgba(255,255,255,0.12);
}
.panel { padding: 24px; }
.stat-card { padding: 20px; position: relative; overflow: hidden; }
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0.6;
}
.stat-card span { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card strong { display: block; margin-top: 10px; font-size: 28px; font-weight: 800; font-family: var(--font-mono); color: var(--text-primary); }
.stat-card .muted { margin-top: 6px; font-size: 12px; }
.taxpayer-card { padding: 20px; }

/* Panel Header */
.panel-header, .section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}
.panel-header h2, .section-head h2, .modal-box h2 {
    font-size: 18px;
    font-weight: 700;
}
.muted { color: var(--text-secondary); }
p.muted { font-size: 13px; margin-top: 4px; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.field input::placeholder { color: var(--text-muted); }

/* Checkbox */
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}
.checkbox-card:hover { border-color: var(--accent); color: var(--text-primary); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 40px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: var(--text-inverse);
    box-shadow: 0 2px 8px rgba(0,212,255,0.25);
}
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,212,255,0.35);
}
.btn:active { transform: translateY(0); }
.btn.secondary {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
    box-shadow: none;
}
.btn.secondary:hover { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.15); box-shadow: none; }
.btn.danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239,68,68,0.25);
}
.btn.danger:hover { box-shadow: 0 4px 16px rgba(239,68,68,0.35); }
.btn.success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25);
}
.btn.success:hover { box-shadow: 0 4px 16px rgba(16,185,129,0.35); }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
table { min-width: 700px; }
th, td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-subtle);
}
th {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: #f8fafc;
    position: sticky;
    top: 0;
}
td { font-size: 13px; }
tbody tr { transition: background var(--transition-fast); }
tbody tr:hover { background: var(--bg-glass); }
tr.closed { opacity: 0.5; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.3px;
    background: var(--bg-glass-hover);
    color: var(--text-secondary);
}
.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }

/* ---------- Alerts ---------- */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid var(--border-glass);
    background: var(--bg-glass);
    animation: alertIn 300ms ease-out;
}
.alert.success { background: var(--success-soft); border-color: rgba(16,185,129,0.2); color: var(--success); }
.alert.error { background: var(--danger-soft); border-color: rgba(239,68,68,0.2); color: var(--danger); }
.alert.info { background: var(--info-soft); border-color: rgba(59,130,246,0.2); color: var(--info); }
.alert.warning { background: var(--warning-soft); border-color: rgba(245,158,11,0.2); color: var(--warning); }

/* ---------- Toast Notifications ---------- */
.toast-container {
    position: fixed;
    top: 20px; right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}
.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toastIn 400ms ease-out;
    max-width: 380px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }

/* ---------- Login Page ---------- */
.login-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: var(--bg-base);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(0,212,255,0.15) 0%, transparent 70%);
    top: -200px; right: -200px;
    pointer-events: none;
}
.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(0,102,204,0.1) 0%, transparent 70%);
    bottom: -100px; left: -100px;
    pointer-events: none;
}
.login-box {
    width: min(420px, 100%);
    padding: 32px;
    position: relative;
    z-index: 1;
    animation: fadeUp 500ms ease-out;
}
.login-box h1 { margin: 12px 0 24px; font-size: 22px; }
.login-box .btn { width: 100%; margin-top: 4px; }

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    z-index: 50;
}
.modal-overlay.is-open { display: flex; }
.modal-box {
    width: min(440px, 100%);
    padding: 28px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: scaleIn 200ms ease-out;
}
.modal-box p { color: var(--text-secondary); margin-top: 8px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ---------- Search & Filter Bar ---------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
}
.filter-bar input[type="search"],
.filter-bar input[type="text"] {
    flex: 1;
    min-width: 200px;
    min-height: 38px;
    padding: 8px 14px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast);
}
.filter-bar input:focus { border-color: var(--accent); }
.filter-bar select {
    min-height: 38px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
}

/* ---------- Pagination ---------- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-subtle);
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}
.pagination a:hover { background: var(--bg-glass-hover); color: var(--text-primary); }
.pagination .active { background: var(--accent-soft); color: var(--accent); }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

/* ---------- Spacing Utilities ---------- */
.mt-sm { margin-top: 12px; }
.mt-md { margin-top: 20px; }
.mt-lg { margin-top: 32px; }
.gap-sm { gap: 8px; }
.text-mono { font-family: var(--font-mono); }
.text-right { text-align: right; }
.text-center { text-align: center; }

/* ---------- Animations ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes alertIn {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(0,212,255,0.2); }
    50% { box-shadow: 0 0 20px rgba(0,212,255,0.4); }
}

/* ---------- Skeleton Loading ---------- */
.skeleton {
    background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--bg-glass-hover) 50%, var(--bg-elevated) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* ---------- Mobile Bottom Nav ---------- */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-glass);
    padding: 8px 16px;
    z-index: 40;
    justify-content: space-around;
    backdrop-filter: blur(16px);
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast);
}
.bottom-nav a .nav-icon { font-size: 20px; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--accent); }

/* ============================================
   RESPONSIVE: Tablet (768px - 1200px)
   ============================================ */
@media (max-width: 1200px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { transform: translateX(-100%); }
    .sidebar.is-open { transform: translateX(0); }
    .main-content { grid-column: 1; padding: 24px 20px; }
    .hamburger-btn { display: flex; }
    .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
    .form-grid { grid-template-columns: repeat(2, 1fr); }
    .topbar { flex-wrap: wrap; }
    .user-chip { min-width: auto; }
}

/* ============================================
   RESPONSIVE: Phone (<768px)
   ============================================ */
@media (max-width: 768px) {
    body { padding-bottom: 72px; font-size: 13px; }
    .main-content { padding: 16px 14px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
    .topbar h1 { font-size: 22px; }
    .user-chip { width: 100%; text-align: left; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .form-grid, .form-grid.two { grid-template-columns: 1fr; }
    .panel { padding: 16px; }
    .stat-card strong { font-size: 22px; }
    .panel-header, .section-head { flex-direction: column; align-items: flex-start; }
    .filter-bar { flex-direction: column; }
    .filter-bar input[type="search"], .filter-bar input[type="text"] { min-width: 100%; }
    .bottom-nav { display: flex; }
    .actions { flex-direction: column; width: 100%; }
    .actions .btn { width: 100%; }
    .modal-box { padding: 20px; }
    table { min-width: 500px; }
    th, td { padding: 10px 8px; font-size: 12px; }
    .toast-container { top: auto; bottom: 80px; right: 12px; left: 12px; }
    .toast { max-width: 100%; }
    .login-box { padding: 24px; }
}
