/* ===== Brakspear Expenses Tool — Styles ===== */

:root {
    --brand-primary: #0E1B2E;
    --brand-accent: #C5A55A;
    --brand-bg: #F7F8FA;
    --brand-card: #FFFFFF;
    --brand-text: #1A1A1A;
    --brand-text-secondary: #6B7280;
    --brand-border: #E5E7EB;
    --brand-success: #059669;
    --brand-warning: #D97706;
    --brand-danger: #DC2626;
    --brand-info: #2563EB;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

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

body {
    font-family: var(--font-family);
    background: var(--brand-bg);
    color: var(--brand-text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ===== Auth Pages ===== */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--brand-primary);
}

.auth-card {
    background: var(--brand-card);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-primary);
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--brand-accent);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 0.25rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Forms ===== */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--brand-text);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="file"],
select,
textarea {
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--brand-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-family);
    color: var(--brand-text);
    background: var(--brand-card);
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-accent);
    box-shadow: 0 0 0 3px rgba(197, 165, 90, 0.15);
}

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

/* ===== Buttons ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.5;
}

.btn-primary {
    background: var(--brand-primary);
    color: white;
}
.btn-primary:hover { background: #162640; }

.btn-accent {
    background: var(--brand-accent);
    color: var(--brand-primary);
}
.btn-accent:hover { background: #B8953F; }

.btn-secondary {
    background: var(--brand-bg);
    color: var(--brand-text);
    border: 1px solid var(--brand-border);
}
.btn-secondary:hover { background: #EBEDF0; }

.btn-success {
    background: var(--brand-success);
    color: white;
}
.btn-success:hover { opacity: 0.9; }

.btn-danger {
    background: var(--brand-danger);
    color: white;
}
.btn-danger:hover { opacity: 0.9; }

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-full { width: 100%; }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Flash Messages ===== */

.flash {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.flash-error {
    background: #FEF2F2;
    color: var(--brand-danger);
    border: 1px solid #FECACA;
}

.flash-success {
    background: #F0FDF4;
    color: var(--brand-success);
    border: 1px solid #BBF7D0;
}

.flash-warning {
    background: #FFFBEB;
    color: var(--brand-warning);
    border: 1px solid #FDE68A;
}

/* ===== App Shell ===== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--brand-primary);
    color: white;
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 1rem;
}

.sidebar-brand h1 {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
}

.sidebar-brand .brand-subtitle {
    font-size: 0.75rem;
    color: var(--brand-accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav {
    flex: 1;
    padding: 0 0.75rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.nav-item.active {
    color: white;
    background: rgba(197, 165, 90, 0.2);
}

.nav-item .nav-icon {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.4);
    padding: 1rem 0.75rem 0.5rem;
}

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

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--brand-accent);
    color: var(--brand-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.75rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.6875rem;
    color: rgba(255,255,255,0.5);
    text-transform: capitalize;
}

.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 2rem;
    max-width: 1200px;
}

/* ===== Page Header ===== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--brand-primary);
}

.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Cards ===== */

.card {
    background: var(--brand-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.25rem;
}

/* ===== Stats Grid ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--brand-card);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--brand-border);
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-text-secondary);
    margin-bottom: 0.375rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--brand-primary);
}

.stat-value.accent { color: var(--brand-accent); }

/* ===== Table ===== */

.table-container {
    overflow-x: auto;
}

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

thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-text-secondary);
    background: var(--brand-bg);
    border-bottom: 1px solid var(--brand-border);
    white-space: nowrap;
}

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--brand-border);
    vertical-align: middle;
}

tbody tr:hover {
    background: #F9FAFB;
}

tbody tr.clickable {
    cursor: pointer;
}

/* ===== Status Badges ===== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending {
    background: #FEF3C7;
    color: #92400E;
}

.badge-approved {
    background: #D1FAE5;
    color: #065F46;
}

.badge-rejected {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-exported {
    background: #E5E7EB;
    color: #374151;
}

/* ===== Flag Badges ===== */

.flag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.flag-warning {
    background: #FEF3C7;
    color: #92400E;
}

.flag-block {
    background: #FEE2E2;
    color: #991B1B;
}

.flag-info {
    background: #DBEAFE;
    color: #1E40AF;
}

/* ===== Expense Detail ===== */

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--brand-text-secondary);
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--brand-border);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 0.375rem 0;
    font-size: 0.875rem;
}

.detail-label {
    color: var(--brand-text-secondary);
    font-weight: 500;
}

.detail-value {
    font-weight: 600;
    text-align: right;
}

.receipt-preview {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--brand-border);
}

/* ===== Upload Zone ===== */

.upload-zone {
    border: 2px dashed var(--brand-border);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
    background: #FAFBFC;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--brand-accent);
    background: #FFFDF5;
}

.upload-zone-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--brand-text-secondary);
}

.upload-zone-text {
    font-size: 0.875rem;
    color: var(--brand-text-secondary);
}

.upload-zone-text strong {
    color: var(--brand-accent);
}

/* ===== Filters Bar ===== */

.filters-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters-bar select,
.filters-bar input {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    min-width: 140px;
}

/* ===== Modal ===== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.active {
    display: flex;
}

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

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--brand-text-secondary);
    padding: 0.25rem;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--brand-border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* ===== Empty State ===== */

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--brand-text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--brand-text);
    margin-bottom: 0.5rem;
}

.empty-state p {
    font-size: 0.875rem;
    max-width: 400px;
    margin: 0 auto;
}

/* ===== Loading Spinner ===== */

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--brand-border);
    border-top-color: var(--brand-accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

.loading-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255,255,255,0.8);
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-overlay.active {
    display: flex;
}

/* ===== Toast Notifications ===== */

.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: #065F46;
    color: white;
}

.toast-error {
    background: #991B1B;
    color: white;
}

.toast-warning {
    background: #92400E;
    color: white;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== Responsive ===== */

.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--brand-primary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .mobile-menu-toggle {
        display: block;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 1.5rem;
    }
}

/* ===== Mileage Form ===== */

.mileage-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

/* ===== Approval Actions ===== */

.approval-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.bulk-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: var(--brand-bg);
    border-bottom: 1px solid var(--brand-border);
}

.bulk-actions .selected-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand-text-secondary);
}

/* ===== Tabs ===== */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--brand-border);
    margin-bottom: 1.5rem;
}

.tab {
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--brand-text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

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

.tab.active {
    color: var(--brand-accent);
    border-bottom-color: var(--brand-accent);
}
