/* =============================================
   Visa Appointment System - Main Stylesheet
   ============================================= */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #1e3a5f;
    --primary-light: #2d5a9b;
    --primary-dark: #122540;
    --accent: #f59e0b;
    --accent-light: #fcd34d;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-600: #475569;
    --gray-800: #1e293b;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --border-radius: 12px;
    --shadow: 0 4px 24px rgba(30,58,95,0.10);
    --shadow-sm: 0 2px 8px rgba(30,58,95,0.07);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; font-size: 15px; background: #f0f4f8; color: var(--gray-800); }

/* ---- SIDEBAR ---- */
#sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width); height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    color: #fff; z-index: 1000; display: flex; flex-direction: column;
    transition: transform 0.3s ease; overflow-y: auto;
    box-shadow: 4px 0 20px rgba(0,0,0,0.18);
}

.sidebar-brand {
    padding: 24px 20px 18px; border-bottom: 1px solid rgba(255,255,255,0.12);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .brand-icon {
    width: 44px; height: 44px; background: var(--accent);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.sidebar-brand h2 { font-size: 15px; font-weight: 700; line-height: 1.3; }
.sidebar-brand p { font-size: 11px; opacity: 0.7; font-weight: 400; }

.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section { padding: 10px 16px 4px; font-size: 10px; font-weight: 700; letter-spacing: 1.2px; opacity: 0.5; text-transform: uppercase; }

.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px; color: rgba(255,255,255,0.8); text-decoration: none;
    font-size: 13.5px; font-weight: 500; border-radius: 0; transition: all 0.2s;
    border-left: 3px solid transparent; margin: 2px 0;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,0.12); color: #fff;
    border-left-color: var(--accent);
}
.sidebar-nav a .nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid rgba(255,255,255,0.12); }

/* ---- MAIN LAYOUT ---- */
#main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh; display: flex; flex-direction: column;
}

/* ---- TOPBAR ---- */
.topbar {
    height: var(--topbar-height); background: #fff;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px; box-shadow: 0 2px 8px rgba(30,58,95,0.07);
    position: sticky; top: 0; z-index: 100;
    border-bottom: 2px solid var(--gray-100);
}
.topbar-title { font-size: 18px; font-weight: 700; color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.user-badge {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px; background: var(--gray-100);
    border-radius: 50px; font-size: 13px; font-weight: 500;
}
.user-badge .avatar {
    width: 32px; height: 32px; background: var(--primary);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; font-weight: 700;
}
.role-badge {
    font-size: 10px; font-weight: 700; padding: 2px 8px;
    border-radius: 20px; letter-spacing: 0.5px; text-transform: uppercase;
}
.role-badge.admin { background: #fef3c7; color: #92400e; }
.role-badge.staff { background: #dbeafe; color: #1e40af; }
.role-badge.viewer { background: #f0fdf4; color: #166534; }

/* ---- PAGE CONTENT ---- */
.page-content { padding: 28px; flex: 1; }

/* ---- CARDS ---- */
.card {
    background: #fff; border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
    overflow: hidden;
}
.card.no-overflow { overflow: visible; }
.card-header {
    padding: 16px 24px; border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
    background: #fff;
}
.card-header h5 { font-size: 16px; font-weight: 700; color: var(--primary); margin: 0; }
.card-body { padding: 24px; }

/* ---- STAT CARDS ---- */
.stat-card {
    border-radius: var(--border-radius); padding: 24px;
    position: relative; overflow: hidden; transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-icon {
    position: absolute; right: 20px; top: 20px;
    font-size: 42px; opacity: 0.2;
}
.stat-card .stat-value { font-size: 32px; font-weight: 800; color: #fff; }
.stat-card .stat-label { font-size: 13px; font-weight: 500; color: rgba(255,255,255,0.85); margin-top: 4px; }
.stat-card .stat-sub { font-size: 12px; color: rgba(255,255,255,0.65); margin-top: 8px; }
.bg-gradient-primary { background: linear-gradient(135deg, #1e3a5f 0%, #2d5a9b 100%); }
.bg-gradient-success { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.bg-gradient-warning { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%); }
.bg-gradient-danger { background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%); }
.bg-gradient-info { background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); }

/* ---- BUTTONS ---- */
.btn { border-radius: 8px; font-weight: 600; font-size: 13px; padding: 8px 18px; transition: all 0.2s; border: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: #1d4ed8; color: #fff; }
.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ---- TABLES ---- */
.table-container { overflow-x: auto; border-radius: var(--border-radius); }
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead th {
    background: var(--primary); color: #fff;
    padding: 12px 16px; font-weight: 600; font-size: 12px;
    letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap;
}
.data-table tbody tr { border-bottom: 1px solid var(--gray-100); transition: background 0.15s; }
.data-table tbody tr:hover { background: #f8faff; }
.data-table tbody td { padding: 12px 16px; vertical-align: middle; }
.data-table tbody tr:last-child { border-bottom: none; }

/* ---- BADGES ---- */
.badge { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; }
.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-primary { background: #dbeafe; color: #1e3a5f; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-weight: 600; font-size: 13px; color: var(--gray-600); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 14px;
    border: 2px solid var(--gray-200); border-radius: 8px;
    font-size: 14px; font-family: 'Inter', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff; color: var(--gray-800);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,58,95,0.10); }
.form-control.is-invalid { border-color: var(--danger); }
.field-validation-error { color: var(--danger); font-size: 12px; margin-top: 4px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 12px center; background-size: 14px; padding-right: 40px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---- SEARCH PANEL ---- */
.search-panel {
    background: #fff; border-radius: var(--border-radius);
    padding: 20px 24px; margin-bottom: 20px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--gray-200);
}
.search-panel .panel-title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ---- ALERTS ---- */
.alert { padding: 12px 18px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---- PAGE HEADER ---- */
.page-header { margin-bottom: 24px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 22px; font-weight: 800; color: var(--primary); }
.page-header .breadcrumb { font-size: 12px; color: var(--gray-600); display: flex; align-items: center; gap: 6px; }
.page-header .breadcrumb a { color: var(--primary-light); text-decoration: none; }

/* ---- GRID ---- */
.row { display: flex; flex-wrap: wrap; gap: 20px; }
.row > * { flex: 1 1 auto; }
.col-12 { width: 100%; }
.col-6 { flex: 0 0 calc(50% - 10px); }
.col-4 { flex: 0 0 calc(33.333% - 14px); }
.col-3 { flex: 0 0 calc(25% - 15px); }
.col-8 { flex: 0 0 calc(66.666% - 7px); }

/* ---- PRINT STYLES ---- */
@media print {
    #sidebar, .topbar, .no-print, .btn, .page-header .btn { display: none !important; }
    #main-content { margin-left: 0 !important; }
    .page-content { padding: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: none !important; }
    .invoice-print { max-width: 100% !important; }
}

/* ---- INVOICE ---- */
.invoice-container {
    max-width: 820px; margin: 0 auto; background: #fff;
    border-radius: var(--border-radius); box-shadow: var(--shadow); overflow: hidden;
}
.invoice-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff; padding: 32px 40px;
    display: flex; justify-content: space-between; align-items: flex-start;
}
.invoice-header h1 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; }
.invoice-header .company-name { font-size: 22px; font-weight: 800; }
.invoice-header .company-details { font-size: 13px; opacity: 0.8; margin-top: 6px; line-height: 1.8; }
.invoice-body { padding: 32px 40px; }
.invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
.invoice-meta-box { background: var(--gray-100); border-radius: 10px; padding: 18px; }
.invoice-meta-box h4 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-600); margin-bottom: 10px; }
.invoice-meta-box p { font-size: 14px; font-weight: 600; color: var(--gray-800); margin: 4px 0; }
.invoice-meta-box span { color: var(--gray-600); font-weight: 400; font-size: 13px; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 24px; }
.invoice-table thead th { background: var(--gray-100); padding: 10px 14px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-600); border-bottom: 2px solid var(--gray-200); }
.invoice-table tbody td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); font-size: 14px; }
.invoice-total { background: var(--primary); color: #fff; border-radius: 10px; padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; }
.invoice-total .total-label { font-size: 15px; font-weight: 600; }
.invoice-total .total-value { font-size: 26px; font-weight: 800; }
.invoice-footer { padding: 24px 40px; border-top: 2px dashed var(--gray-200); display: flex; justify-content: space-between; color: var(--gray-600); font-size: 12px; }
.signature-box { text-align: center; }
.signature-line { width: 180px; height: 1px; background: var(--gray-300); margin: 50px auto 8px; }

/* ---- VOUCHER ---- */
.voucher-container { max-width: 600px; margin: 0 auto; }
.voucher-header { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); color: #fff; padding: 24px 32px; border-radius: var(--border-radius) var(--border-radius) 0 0; text-align: center; }
.voucher-body { background: #fff; padding: 28px 32px; border-radius: 0 0 var(--border-radius) var(--border-radius); box-shadow: var(--shadow); border: 2px dashed var(--gray-200); border-top: none; }
.voucher-no { font-size: 20px; font-weight: 800; color: var(--accent); letter-spacing: 2px; }
.voucher-amount { font-size: 36px; font-weight: 800; color: var(--primary); text-align: center; padding: 24px 0; border-top: 2px dashed var(--gray-200); border-bottom: 2px dashed var(--gray-200); margin: 20px 0; }
.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.detail-row .label { color: var(--gray-600); font-weight: 500; }
.detail-row .value { font-weight: 700; color: var(--gray-800); }

/* ---- 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(--primary-light) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 20px; padding: 48px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .logo-icon { width: 72px; height: 72px; background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%); border-radius: 20px; display: flex; align-items: center; justify-content: center; font-size: 34px; margin: 0 auto 16px; }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--primary); }
.login-logo p { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
    #sidebar { transform: translateX(-100%); }
    #sidebar.open { transform: translateX(0); }
    #main-content { margin-left: 0; }
}

/* ---- RTL SUPPORT ---- */
[dir="rtl"] { text-align: right; }
[dir="rtl"] #sidebar { left: auto; right: 0; box-shadow: -4px 0 20px rgba(0,0,0,0.18); border-left: 1px solid rgba(255,255,255,0.12); border-right: none; }
[dir="rtl"] #main-content { margin-left: 0; margin-right: var(--sidebar-width); }
[dir="rtl"] .sidebar-nav a { border-left: none; border-right: 3px solid transparent; }
[dir="rtl"] .sidebar-nav a:hover, [dir="rtl"] .sidebar-nav a.active { border-right-color: var(--accent); }
[dir="rtl"] .topbar { left: 0; right: var(--sidebar-width); }
[dir="rtl"] .user-badge { flex-direction: row-reverse; }
[dir="rtl"] .btn i, [dir="rtl"] .nav-icon { margin-left: 0; }
[dir="rtl"] .sidebar-brand { gap: 12px; flex-direction: row-reverse; }
[dir="rtl"] .invoice-header { flex-direction: row-reverse; }
[dir="rtl"] .invoice-meta { direction: rtl; }
[dir="rtl"] .invoice-total { flex-direction: row-reverse; }
[dir="rtl"] .signature-box { text-align: center; }

@media (max-width: 992px) {
    [dir="rtl"] #sidebar { transform: translateX(100%); }
    [dir="rtl"] #sidebar.open { transform: translateX(0); }
    [dir="rtl"] #main-content { margin-right: 0; }
}