/* Treasury Management System - Holol Al-Tawasul Branding */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Cairo:wght@300;400;600;700&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-light: #2a5082;
    --primary-dark: #142942;
    --cyan: #00b4d8;
    --cyan-light: #48cae4;
    --cyan-dark: #0096c7;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --purple: #8b5cf6;
    --orange: #f97316;
    --teal: #14b8a6;
    --bg-body: #f0f4f8;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --sidebar-width: 240px;
    --header-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-xs: 6px;
    --shadow-sm: 0 1px 2px rgba(30,58,95,0.06);
    --shadow: 0 2px 8px rgba(30,58,95,0.08);
    --shadow-md: 0 4px 16px rgba(30,58,95,0.1);
    --shadow-lg: 0 8px 32px rgba(30,58,95,0.12);
}

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

body {
    font-family: 'Inter', 'Cairo', sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo h2 {
    color: white;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.sidebar-logo small {
    color: var(--cyan-light);
    font-size: 11px;
    font-weight: 500;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
}

.nav-section-label {
    color: rgba(255,255,255,0.4);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 12px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-xs);
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    position: relative;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(0,180,216,0.15);
    color: white;
}

.nav-item.active {
    background: rgba(0,180,216,0.2);
    color: white;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--cyan);
    border-radius: 0 3px 3px 0;
}

.nav-item i { width: 18px; text-align: center; font-size: 14px; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 12px;
}

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
}

/* ===== Main Content ===== */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
}

.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--cyan-dark);
    text-decoration: none;
    font-weight: 500;
}

.breadcrumb .sep { color: var(--text-muted); }
.breadcrumb .current { color: var(--text-primary); font-weight: 600; }

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    position: relative;
}

.header-btn:hover { background: var(--bg-body); color: var(--primary); }

.header-btn .badge-dot {
    position: absolute;
    top: 6px; right: 6px;
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--danger);
    border: 2px solid white;
}

.content { padding: 24px; }

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
}

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

.card-title {
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}

.card-title i { color: var(--cyan); }

.card-body { padding: 16px 20px; }

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    background: #fafbfc;
}

/* ===== KPI Cards ===== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.kpi-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
}

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

.kpi-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 3px;
}

.kpi-card.blue::after { background: linear-gradient(90deg, var(--primary), var(--cyan)); }
.kpi-card.green::after { background: linear-gradient(90deg, #059669, var(--success)); }
.kpi-card.purple::after { background: linear-gradient(90deg, #7c3aed, var(--purple)); }
.kpi-card.orange::after { background: linear-gradient(90deg, #ea580c, var(--orange)); }
.kpi-card.teal::after { background: linear-gradient(90deg, #0d9488, var(--teal)); }
.kpi-card.red::after { background: linear-gradient(90deg, #dc2626, var(--danger)); }
.kpi-card.cyan::after { background: linear-gradient(90deg, var(--cyan-dark), var(--cyan-light)); }

.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.kpi-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.kpi-card.blue .kpi-icon { background: rgba(30,58,95,0.1); color: var(--primary); }
.kpi-card.green .kpi-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.kpi-card.purple .kpi-icon { background: rgba(139,92,246,0.1); color: var(--purple); }
.kpi-card.orange .kpi-icon { background: rgba(249,115,22,0.1); color: var(--orange); }
.kpi-card.teal .kpi-icon { background: rgba(20,184,166,0.1); color: var(--teal); }
.kpi-card.red .kpi-icon { background: rgba(239,68,68,0.1); color: var(--danger); }
.kpi-card.cyan .kpi-icon { background: rgba(0,180,216,0.1); color: var(--cyan); }

.kpi-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-value .unit {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-left: 4px;
}

.kpi-change {
    font-size: 11px;
    font-weight: 600;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }

/* ===== Categories Grid (Functions Landing Page) ===== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 24px;
    padding: 0;
}

.category-card {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.3s;
    box-shadow: var(--shadow);
}

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

.category-header {
    padding: 24px;
    text-align: center;
    color: white;
    position: relative;
}

.category-header h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.category-header .count {
    font-size: 12px;
    opacity: 0.85;
}

.category-header .cat-icon {
    font-size: 28px;
    margin-bottom: 10px;
    opacity: 0.9;
}

.category-body { padding: 16px; }

.func-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    margin-bottom: 4px;
}

.func-item:hover {
    background: #f1f5f9;
    transform: translateX(4px);
}

.func-item-icon {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.func-item-text { flex: 1; }

.func-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.func-item-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.func-item-arrow {
    color: var(--text-muted);
    font-size: 12px;
    transition: transform 0.2s;
}

.func-item:hover .func-item-arrow { transform: translateX(4px); color: var(--cyan); }

/* Category colors */
.cat-bg { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); }
.cat-bg .func-item-icon { background: rgba(30,58,95,0.08); color: var(--primary); }

.cat-lc { background: linear-gradient(135deg, var(--cyan-dark) 0%, var(--cyan) 100%); }
.cat-lc .func-item-icon { background: rgba(0,180,216,0.08); color: var(--cyan-dark); }

.cat-pay { background: linear-gradient(135deg, #059669 0%, var(--success) 100%); }
.cat-pay .func-item-icon { background: rgba(16,185,129,0.08); color: #059669; }

.cat-loan { background: linear-gradient(135deg, #7c3aed 0%, var(--purple) 100%); }
.cat-loan .func-item-icon { background: rgba(139,92,246,0.08); color: #7c3aed; }

.cat-report { background: linear-gradient(135deg, #ea580c 0%, var(--orange) 100%); }
.cat-report .func-item-icon { background: rgba(249,115,22,0.08); color: #ea580c; }

.cat-admin { background: linear-gradient(135deg, #0d9488 0%, var(--teal) 100%); }
.cat-admin .func-item-icon { background: rgba(20,184,166,0.08); color: #0d9488; }

.cat-coming { background: linear-gradient(135deg, #475569 0%, #64748b 100%); }
.cat-coming .func-item-icon { background: rgba(100,116,139,0.08); color: #64748b; }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

table thead th {
    background: #f8fafc;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table tbody td {
    padding: 10px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

table tbody tr:hover { background: #f8fafc; }
table tbody tr:last-child td { border-bottom: none; }

.amount-cell { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success { background: #d1fae5; color: #059669; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-danger { background: #fee2e2; color: #dc2626; }
.badge-info { background: #dbeafe; color: #2563eb; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: rgba(30,58,95,0.1); color: var(--primary); }
.badge-cyan { background: rgba(0,180,216,0.1); color: var(--cyan-dark); }

/* ===== Progress Bars ===== */
.progress-bar {
    height: 8px;
    background: #f1f5f9;
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease;
}

.progress-bar .fill.blue { background: linear-gradient(90deg, var(--primary), var(--cyan)); }
.progress-bar .fill.green { background: linear-gradient(90deg, #059669, var(--success)); }
.progress-bar .fill.red { background: linear-gradient(90deg, #dc2626, var(--danger)); }
.progress-bar .fill.orange { background: linear-gradient(90deg, #ea580c, var(--orange)); }

.util-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.util-cell .progress-bar { flex: 1; min-width: 60px; }
.util-cell .pct { font-size: 11px; font-weight: 600; color: var(--text-secondary); min-width: 35px; }

/* ===== Forms ===== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(0,180,216,0.1);
}

select.form-control { cursor: pointer; }

textarea.form-control { min-height: 80px; resize: vertical; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-cyan {
    background: var(--cyan);
    color: white;
}
.btn-cyan:hover { background: var(--cyan-dark); }

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

.btn-outline {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-body); }

.btn-sm { padding: 5px 12px; font-size: 12px; }

.btn-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ===== Grid Layouts ===== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
}

.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
}

.grid-1-2 {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 16px;
}

/* ===== Chart Container ===== */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-container canvas { width: 100% !important; }

/* ===== Filters Bar ===== */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filters-bar .form-control {
    width: auto;
    min-width: 150px;
    padding: 7px 12px;
    font-size: 12px;
}

.filters-bar .search-input {
    flex: 1;
    min-width: 200px;
}

/* ===== Page Header ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h4 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--cyan-dark) 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

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

.login-logo h1 {
    font-size: 22px;
    color: var(--primary);
    font-weight: 800;
    margin-bottom: 4px;
}

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

.login-error {
    background: #fee2e2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* ===== Locked/Coming Soon Items ===== */
.func-item.locked {
    opacity: 0.5;
    cursor: default;
}

.func-item.locked:hover {
    background: transparent;
    transform: none;
}

.lock-icon {
    color: var(--text-muted);
    font-size: 11px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 16px;
}

.tab {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover { color: var(--primary); }

.tab.active {
    color: var(--cyan-dark);
    border-bottom-color: var(--cyan);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

.modal-body { padding: 20px; }

.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ===== Notification Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    background: white;
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--success);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    font-weight: 500;
    transform: translateX(120%);
    transition: transform 0.3s;
}

.toast.show { transform: translateX(0); }
.toast.error { border-left-color: var(--danger); }

/* ===== Loading Spinner ===== */
.spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--cyan);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .grid-2, .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .categories-grid { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .categories-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .filters-bar { flex-direction: column; }
    .filters-bar .form-control { width: 100%; }
}

/* ===== Animations ===== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* ===== Page visibility ===== */
.page { display: none; }
.page.active { display: block; }

/* ===== Mobile menu toggle ===== */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-primary);
    cursor: pointer;
}

@media (max-width: 768px) {
    .menu-toggle { display: block; }
    .sidebar.open { display: flex; }
}
