/* ============================================
   SRC Query Management System - External CSS
   cre8learn Institute
   ============================================ */

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

:root {
    --primary: #6A1E2A;
    --primary-dark: #4F1620;
    --primary-light: #8F3B48;
    --finance: #1E3A5F;
    --finance-light: #2A5280;
    --bg: #F9F6F6;
    --white: #FFFFFF;
    --text: #1E1B1C;
    --text-light: #5A4B4F;
    --border: #EAD5D8;
    --success: #2E7D32;
    --warning: #C17F1F;
    --danger: #B71C2C;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* ============================================
   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) 100%);
    padding: 20px;
}

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

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

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

.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--primary);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 24px;
    color: var(--primary-dark);
}

.login-logo p {
    color: var(--text-light);
    font-size: 14px;
    margin-top: 4px;
}

.login-form .form-group {
    margin-bottom: 18px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(106, 30, 42, 0.1);
}

.login-btn {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.login-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

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

.login-error.show {
    display: block;
}

.login-role-hint {
    text-align: center;
    margin-top: 16px;
    font-size: 12px;
    color: var(--text-light);
}

.login-role-hint span {
    font-weight: 600;
}

/* ============================================
   MAIN APP
   ============================================ */
.app-container {
    display: none;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.app-container.show {
    display: block;
}

/* Header */
.header {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

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

.logo {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 18px;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
}

.header-title p {
    font-size: 13px;
    color: var(--text-light);
}

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

.role-badge {
    font-size: 12px;
    padding: 6px 16px;
    border-radius: 40px;
    font-weight: 600;
    background: var(--primary);
    color: white;
}

.role-badge.finance {
    background: var(--finance);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-light);
}

.user-info i {
    font-size: 18px;
    color: var(--primary);
}

.logout-btn {
    padding: 8px 18px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: 40px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-light);
    font-family: inherit;
}

.logout-btn:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Firebase Status */
.firebase-status {
    background: #E8F5E9;
    border-left: 4px solid var(--success);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.firebase-status.error {
    background: #FCEAEA;
    border-left-color: var(--danger);
}

.firebase-status.warning {
    background: #FFF3E0;
    border-left-color: var(--warning);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    background: var(--white);
    padding: 4px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.tab {
    padding: 10px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.tab:hover {
    background: var(--bg);
}

.tab.active {
    background: var(--primary);
    color: white;
}

.tab.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* Sections */
.section {
    display: none;
}

.section.active {
    display: block;
}

/* Panels */
.panel {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.panel-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-title i {
    color: var(--primary);
}

.panel-subtitle {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
}

label .required {
    color: var(--danger);
}

input, select, textarea {
    font-family: inherit;
    font-size: 14px;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    background: var(--white);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(106, 30, 42, 0.1);
}

input:disabled, select:disabled, textarea:disabled {
    background: #F5F5F5;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Package Grid */
.pkg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}

.pkg-card {
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

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

.pkg-card.selected {
    border-color: var(--primary);
    background: #FEF5F5;
    box-shadow: 0 0 0 3px rgba(106, 30, 42, 0.1);
}

.pkg-gb {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary-dark);
}

.pkg-label {
    font-size: 12px;
    color: var(--text-light);
}

/* Allowance Pills */
.allowance-pkg {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.allowance-pill {
    padding: 10px 22px;
    border: 2px solid var(--border);
    border-radius: 40px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    background: var(--white);
}

.allowance-pill:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.allowance-pill.selected {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 40px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
}

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

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

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

.btn-finance {
    background: var(--finance);
    color: white;
}

.btn-finance:hover {
    background: var(--finance-light);
}

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

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-group {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Metrics */
.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric {
    background: var(--white);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    margin-top: 4px;
}

/* Table */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    text-align: left;
    padding: 12px 10px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-light);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tr:hover td {
    background: var(--bg);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.pending {
    background: #FFF3E0;
    color: var(--warning);
}

.status-badge.resolved {
    background: #E8F5E9;
    color: var(--success);
}

.status-badge.escalated {
    background: #FCEAEA;
    color: var(--danger);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.pending { background: var(--warning); }
.dot.resolved { background: var(--success); }
.dot.escalated { background: var(--danger); }

.type-badge {
    padding: 4px 12px;
    border-radius: 40px;
    font-size: 12px;
    font-weight: 600;
}

.type-badge.data {
    background: #E3F2FD;
    color: #0D47A1;
}

.type-badge.allowance {
    background: #FFF3E0;
    color: #A86015;
}

/* Filter Row */
.filter-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.filter-row input, .filter-row select {
    min-width: 160px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.open {
    display: flex;
}

.modal-card {
    background: var(--white);
    border-radius: 16px;
    padding: 28px;
    width: 500px;
    max-width: 92vw;
    max-height: 80vh;
    overflow-y: auto;
    border-top: 5px solid var(--primary);
    animation: modalSlide 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.field-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.field-key {
    font-weight: 500;
    color: var(--text-light);
}

.field-value {
    font-weight: 500;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    border-radius: 40px;
    font-weight: 500;
    z-index: 1100;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.toast.show {
    opacity: 1;
    pointer-events: auto;
}

.toast.success {
    background: var(--success);
    color: white;
}

.toast.error {
    background: var(--danger);
    color: white;
}

.toast.info {
    background: var(--finance);
    color: white;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

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

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.chart-box {
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chart-box h4 {
    margin-bottom: 12px;
    font-size: 14px;
    color: var(--text-light);
}

.chart-box canvas {
    max-height: 200px;
    width: 100% !important;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .container {
        padding: 12px;
    }
    
    .header {
        padding: 16px;
    }
    
    .header-title h1 {
        font-size: 17px;
    }
    
    .login-card {
        padding: 32px 24px;
    }
    
    .panel {
        padding: 16px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tab {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-card {
        padding: 20px;
        max-height: 90vh;
    }
    
    .filter-row input, .filter-row select {
        min-width: 120px;
        flex: 1;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .user-info {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .metrics {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .metric-value {
        font-size: 22px;
    }
    
    .pkg-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .allowance-pkg {
        gap: 6px;
    }
    
    .allowance-pill {
        padding: 8px 16px;
        font-size: 13px;
    }
}
