/* ============================================================
   Markato Biometric Platform — Global Stylesheet
   ============================================================ */

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body, #app {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    background: #F8FAFC;
    color: #0F172A;
    min-height: 100vh;
}

a { color: #C00000; text-decoration: none; }
a:hover { color: #8B0000; }

/* ============================================================
   APP SHELL
   ============================================================ */
.app-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.app-sidebar {
    background: #ffffff;
    color: #475569;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    z-index: 200;
    border-right: 1px solid #E2E8F0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    background: #ffffff;
    border-bottom: 1px solid #E2E8F0;
    flex-shrink: 0;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: 8px;
    padding: 4px;
    object-fit: contain;
    flex-shrink: 0;
    border: 1px solid #E2E8F0;
}

.sidebar-title {
    font-size: 16px;
    font-weight: 700;
    color: #0F172A;
}

.nav-wrapper { padding: 10px 0; flex: 1; }
.nav-section { margin-bottom: 4px; }

.nav-section-label {
    padding: 14px 20px 6px 20px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    color: #94A3B8;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #475569 !important;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none !important;
    transition: all 0.12s;
    border-left: 3px solid transparent;
    margin: 2px 0;
}

.nav-item-link:hover {
    background: #F8FAFC !important;
    color: #0F172A !important;
}

.nav-item-link.active {
    background: #FEF2F2 !important;
    color: #C00000 !important;
    border-left-color: #C00000 !important;
    font-weight: 600 !important;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ============================================================
   MAIN AREA
   ============================================================ */
.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
}

.app-topbar {
    height: 68px;
    background: #ffffff;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.topbar-title { font-size: 15px; font-weight: 700; color: #0F172A; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-right: 16px;
    border-right: 1px solid #E2E8F0;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #C00000;
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; color: #0F172A; line-height: 1.2; }
.user-role { font-size: 11px; color: #64748B; line-height: 1.2; }

.topbar-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #64748B;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 8px;
    flex-shrink: 0;
}

.topbar-logout:hover { background: #FEF2F2; color: #C00000; }

.menu-toggle { display: none; }

/* ---------- CRITICAL: no overflow-x here, or the modal breaks ---------- */
.app-content {
    flex: 1;
    padding: 0;
    min-width: 0;
}

/* ============================================================
   PAGE COMPONENTS
   ============================================================ */
.page-container { padding: 28px 32px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title { font-size: 22px; font-weight: 700; color: #0F172A; margin: 0 0 4px 0; }
.page-subtitle { font-size: 13.5px; color: #64748B; margin: 0; }

/* Welcome banner */
.welcome-banner {
    background: linear-gradient(135deg, #C00000 0%, #8B0000 100%);
    border-radius: 14px;
    padding: 32px;
    color: white;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.welcome-banner h1 { font-size: 26px; font-weight: 800; color: white; margin-bottom: 8px; }
.welcome-banner p { font-size: 14px; color: rgba(255, 255, 255, 0.88); }
.banner-time { font-size: 38px; font-weight: 800; color: white; line-height: 1; }
.banner-date { font-size: 12.5px; color: rgba(255, 255, 255, 0.85); margin-top: 6px; text-align: right; }

/* Stat cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 22px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border-left: 4px solid transparent;
}

.stat-card-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: #64748B; margin-bottom: 8px; }
.stat-card-value { font-size: 30px; font-weight: 800; line-height: 1; color: #0F172A; }
.stat-card-sub { font-size: 12px; color: #94A3B8; margin-top: 6px; }

.stat-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-blue { border-left-color: #1E40AF; }
.stat-blue .stat-card-icon { background: #EFF6FF; color: #1E40AF; }
.stat-blue .stat-card-value { color: #1E40AF; }

.stat-green { border-left-color: #047857; }
.stat-green .stat-card-icon { background: #ECFDF5; color: #047857; }
.stat-green .stat-card-value { color: #047857; }

.stat-orange { border-left-color: #C2410C; }
.stat-orange .stat-card-icon { background: #FFF7ED; color: #C2410C; }
.stat-orange .stat-card-value { color: #C2410C; }

.stat-purple { border-left-color: #6D28D9; }
.stat-purple .stat-card-icon { background: #F5F3FF; color: #6D28D9; }
.stat-purple .stat-card-value { color: #6D28D9; }

.stat-red { border-left-color: #C00000; }
.stat-red .stat-card-icon { background: #FEF2F2; color: #C00000; }
.stat-red .stat-card-value { color: #C00000; }

.stat-gray { border-left-color: #475569; }
.stat-gray .stat-card-icon { background: #F1F5F9; color: #475569; }
.stat-gray .stat-card-value { color: #475569; }

/* Section cards */
.section-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 24px;
}

.section-title { font-size: 16px; font-weight: 700; color: #0F172A; margin-bottom: 18px; }

.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.quick-action {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    background: #F8FAFC;
    color: #334155;
    font-family: inherit;
}

.quick-action:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.quick-action.qa-red { background: #FEF2F2; color: #991B1B; }
.quick-action.qa-blue { background: #EFF6FF; color: #1E40AF; }
.quick-action.qa-green { background: #ECFDF5; color: #065F46; }
.quick-action.qa-orange { background: #FFF7ED; color: #9A3412; }
.quick-action.qa-purple { background: #F5F3FF; color: #6D28D9; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #C00000;
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}
.btn-primary:hover:not(:disabled) { background: #8B0000; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: #F1F5F9;
    color: #334155;
    border: 1px solid #E2E8F0;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-icon {
    background: transparent;
    border: 1px solid #E2E8F0;
    color: #64748B;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { background: #C00000; color: white; border-color: #C00000; }

/* ============================================================
   FILTERS
   ============================================================ */
.filters-bar {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    background: white;
    padding: 18px 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group { display: flex; flex-direction: column; gap: 6px; min-width: 180px; }
.filter-group label { font-size: 11px; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: 0.5px; }
.filter-group select { padding: 9px 12px; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 13.5px; background: #F8FAFC; color: #0F172A; outline: none; font-family: inherit; }
.filter-actions { margin-left: auto; min-width: auto; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow-x: auto;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.data-table thead { background: #F8FAFC; }
.data-table th { text-align: left; padding: 14px 18px; font-size: 11px; font-weight: 700; color: #64748B; text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid #E2E8F0; white-space: nowrap; }
.data-table td { padding: 14px 18px; border-bottom: 1px solid #F1F5F9; color: #334155; vertical-align: middle; }
.data-table tbody tr:hover { background: #F8FAFC; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ============================================================
   BADGES
   ============================================================ */
.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: #F1F5F9; color: #475569; }
.badge-code { background: #F1F5F9; color: #0F172A; font-family: monospace; }
.badge-green { background: #ECFDF5; color: #047857; }
.badge-orange { background: #FFF7ED; color: #C2410C; }
.badge-purple { background: #F5F3FF; color: #6D28D9; }
.badge-gray { background: #F1F5F9; color: #64748B; }
.badge-red { background: #FEF2F2; color: #991B1B; }

/* ============================================================
   ALERTS / STATES
   ============================================================ */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 13.5px; font-weight: 500; }
.alert-success { background: #ECFDF5; color: #065F46; border-left: 4px solid #047857; }
.alert-error { background: #FEF2F2; color: #991B1B; border-left: 4px solid #C00000; }

.loading-box, .empty-box { background: white; padding: 60px; border-radius: 12px; text-align: center; color: #94A3B8; font-size: 14px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); }

/* ============================================================
   MODAL — TRUE CENTER OF SCREEN
   ============================================================ */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    overflow-y: auto;
}

.modal {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    margin: auto;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 { font-size: 18px; font-weight: 700; margin: 0; color: #0F172A; }
.modal-close { background: none; border: none; font-size: 24px; color: #94A3B8; cursor: pointer; width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center; justify-content: center; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #E2E8F0; display: flex; justify-content: flex-end; gap: 12px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 6px; }

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 14px;
    background: #F8FAFC;
    color: #0F172A;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #C00000;
    background: white;
    box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.1);
}

/* ============================================================
   BLAZOR ERROR
   ============================================================ */
#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #C00000; color: white; padding: 12px; text-align: center; z-index: 9999; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
    .app-shell { grid-template-columns: 1fr; }
    .app-sidebar { position: fixed; left: 0; top: 0; width: 280px; height: 100vh; transform: translateX(-100%); transition: transform 0.25s ease; box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2); }
    .app-sidebar.open { transform: translateX(0); }
    .menu-toggle { display: flex; align-items: center; justify-content: center; background: none; border: none; color: #0F172A; padding: 8px; border-radius: 6px; cursor: pointer; }
    .app-topbar { padding: 0 16px; height: 60px; }
    .topbar-title { font-size: 13.5px; }
    .user-name, .user-role { display: none; }
    .topbar-user { padding-right: 0; border-right: none; }
    .topbar-logout span { display: none; }
    .page-container { padding: 20px 16px; }
    .form-row { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    .modal { max-width: 100%; max-height: 100vh; border-radius: 0; }
    .modal-backdrop { padding: 0; }
}
/* ============================================================
   BULLETPROOF MODAL OVERRIDE
   ============================================================ */
.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
}

.modal {
    position: relative !important;
    margin: auto !important;
    background: #ffffff !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    border-radius: 8px !important;
    max-width: 700px !important;
    width: 95% !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
}
/* ============================================================
   ABSOLUTE FIX FOR MODAL
   ============================================================ */
.app-content {
    position: relative !important;
}

.modal-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 99999 !important;
}

.modal {
    position: relative !important;
    margin: 20px !important;
    background: #ffffff !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    border-radius: 8px !important;
    max-width: 700px !important;
    width: 90% !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
}
/* ============================================================
   DRAWER (Slide-out Panel)
   ============================================================ */
.drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 1040;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    background: white;
    z-index: 1050;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    padding: 24px;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.drawer-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #0F172A;
    margin: 0 0 4px 0;
}

.drawer-header p {
    font-size: 13px;
    color: #64748B;
    margin: 0;
}

.drawer-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.detail-group {
    margin-bottom: 16px;
}

.detail-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748B;
    margin-bottom: 4px;
}

.detail-group div {
    font-size: 14px;
    color: #0F172A;
    font-weight: 500;
}
/* Search input matches filter dropdowns */
.filter-group input {
    padding: 9px 12px;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    font-size: 13.5px;
    background: #F8FAFC;
    color: #0F172A;
    outline: none;
    font-family: inherit;
    width: 100%;
}

.filter-group input:focus {
    border-color: #C00000;
    background: white;
    box-shadow: 0 0 0 3px rgba(192, 0, 0, 0.1);
}
/* ============================================================
   PAGINATION BAR
   ============================================================ */
.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    margin-top: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.pagination-info {
    font-size: 13px;
    color: #64748B;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-size-select {
    padding: 6px 10px;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    font-size: 13px;
    background: #F8FAFC;
    color: #0F172A;
    outline: none;
    margin-right: 12px;
}

.btn-page {
    background: #F1F5F9;
    border: 1px solid #E2E8F0;
    color: #334155;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.btn-page:hover:not(:disabled) {
    background: #E2E8F0;
}

.btn-page:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-indicator {
    background: #C00000;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
}
/* ============================================================
   CUSTOM DROPDOWN MENU
   ============================================================ */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 160px;
    padding: 6px;
    display: flex;
    flex-direction: column;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: #334155;
    cursor: pointer;
    text-align: left;
    width: 100%;
    transition: background 0.12s;
    font-family: inherit;
}

.dropdown-item:hover {
    background: #F8FAFC;
    color: #C00000;
}

.dropdown-item svg {
    color: #64748B;
}

.dropdown-item:hover svg {
    color: #C00000;
}