/* ================================================================
   RAWSO Payroll Portal — Shared Design System
   ================================================================ */

/* ── Design Tokens ──────────────────────────────────────────────── */
:root {
    /* Brand */
    --accent:           #F36E22;
    --accent-hover:     #d85d15;
    --accent-subtle:    rgba(243, 110, 34, 0.08);
    --accent-medium:    rgba(243, 110, 34, 0.15);

    /* Neutral Scale (Cool Slate) */
    --foreground:       #0f172a;
    --secondary:        #475569;
    --muted:            #64748b;
    --faint:            #94a3b8;
    --border:           #e2e8f0;
    --border-subtle:    #f1f5f9;
    --surface:          #ffffff;
    --surface-raised:   #f8fafc;
    --background:       #f1f3f5;
    --nav-bg:           #0f172a;

    /* Semantic Colors */
    --success:          #10b981;
    --success-bg:       rgba(16, 185, 129, 0.08);
    --warning:          #f59e0b;
    --warning-bg:       rgba(245, 158, 11, 0.08);
    --error:            #ef4444;
    --error-bg:         rgba(239, 68, 68, 0.08);
    --info:             #6366f1;
    --info-bg:          rgba(99, 102, 241, 0.08);
    --purple:           #8b5cf6;
    --purple-bg:        rgba(139, 92, 246, 0.08);
    --missing-red:      #dc2626;
    --missing-red-bg:   rgba(220, 38, 38, 0.07);

    /* Typography */
    --font-sans:        'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    --font-mono:        'SF Mono', 'Consolas', 'Monaco', monospace;
    --text-xs:          0.6875rem;
    --text-sm:          0.75rem;
    --text-base:        0.8125rem;
    --text-md:          0.875rem;
    --text-lg:          1rem;
    --text-xl:          1.25rem;
    --text-2xl:         1.5rem;
    --text-3xl:         2rem;

    /* Spacing (4px grid) */
    --space-1:          0.25rem;
    --space-2:          0.5rem;
    --space-3:          0.75rem;
    --space-4:          1rem;
    --space-5:          1.25rem;
    --space-6:          1.5rem;
    --space-8:          2rem;
    --space-10:         2.5rem;
    --space-12:         3rem;
    --space-16:         4rem;

    /* Border Radius */
    --radius-sm:        4px;
    --radius-md:        6px;
    --radius-lg:        8px;
    --radius-xl:        12px;
    --radius-full:      9999px;

    /* Shadows */
    --shadow-sm:        0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md:        0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg:        0 8px 24px rgba(15, 23, 42, 0.12);
    --shadow-overlay:   0 16px 48px rgba(15, 23, 42, 0.2);

    /* Z-Index */
    --z-sticky:         50;
    --z-nav:            100;
    --z-submit-bar:     99;
    --z-toast:          200;
    --z-overlay:        300;

    /* Transitions */
    --transition-fast:  0.15s ease;
    --transition-base:  0.2s ease;
    --transition-slow:  0.3s ease;

    /* Layout */
    --max-width:        1400px;
    --nav-height:       56px;
}

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

body {
    font-family: var(--font-sans);
    background: var(--background);
    min-height: 100vh;
    color: var(--foreground);
    font-size: var(--text-md);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ── Navigation ─────────────────────────────────────────────────── */
.nav {
    background: var(--nav-bg);
    padding: 0 var(--space-8);
    display: flex;
    align-items: center;
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-logo {
    height: 36px;
    margin-right: var(--space-8);
    transition: opacity var(--transition-fast);
}
.nav-logo:hover { opacity: 0.85; }

.nav-links {
    display: flex;
    gap: var(--space-1);
}
.nav-links a {
    color: var(--faint);
    text-decoration: none;
    font-size: var(--text-md);
    font-weight: 500;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.nav-links a:hover {
    color: var(--surface);
    background: rgba(255, 255, 255, 0.06);
}
.nav-links a.active {
    color: #fff;
    background: var(--accent-medium);
}

.nav-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.nav-user {
    color: rgba(255, 255, 255, 0.6);
    font-size: var(--text-base);
    font-weight: 500;
}
.nav-logout {
    color: var(--faint);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 600;
    padding: var(--space-1) var(--space-2);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.nav-logout:hover {
    color: white;
    border-color: rgba(255, 255, 255, 0.3);
}

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: var(--text-base);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    line-height: 1.4;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { filter: brightness(0.92); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary { background: var(--surface); color: var(--foreground); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--foreground); }

.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); font-size: var(--text-base); padding: var(--space-1) var(--space-3); border-radius: var(--radius-md); }
.btn-ghost:hover { color: var(--foreground); border-color: var(--faint); }
.btn-ghost.active-toggle { background: var(--foreground); color: white; border-color: var(--foreground); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(0.92); }
.btn-success:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger { background: var(--error); color: white; }
.btn-danger:hover { filter: brightness(0.92); }

.btn-approve-all { background: var(--success); color: white; }
.btn-approve-all:hover { filter: brightness(0.92); }

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-md);
    border-radius: var(--radius-lg);
    width: 100%;
    justify-content: center;
}

.btn .btn-spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.btn.loading .btn-text { display: none; }
.btn.loading .btn-spinner { display: block; }

/* ── Badges ─────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-success, .badge-ok, .badge-new { background: var(--success-bg); color: var(--success); }
.badge-warning, .badge-tc { background: var(--warning-bg); color: var(--warning); }
.badge-error, .badge-insuff { background: var(--error-bg); color: var(--error); }
.badge-info, .badge-bhr { background: var(--info-bg); color: var(--info); }
.badge-purple, .badge-conflict, .badge-rehire { background: var(--purple-bg); color: var(--purple); }
.badge-neutral { background: var(--surface-raised); color: var(--muted); }

/* ── Cards ──────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.card:hover {
    border-color: var(--faint);
}

/* ── Run Card ───────────────────────────────────────────────────── */
.run-card {
    max-width: 520px;
    margin: var(--space-16) auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out;
}
.run-card-header {
    background: var(--nav-bg);
    padding: var(--space-6) var(--space-8);
    text-align: center;
}
.run-card-header h2 {
    color: var(--surface);
    font-size: var(--text-xl);
    font-weight: 700;
}
.run-card-header p {
    color: var(--faint);
    font-size: var(--text-md);
    margin-top: var(--space-1);
}
.run-card-body {
    padding: var(--space-6) var(--space-8);
}
.run-steps {
    list-style: none;
    margin-bottom: var(--space-6);
}
.run-steps li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: var(--text-md);
}
.run-steps li:last-child { border-bottom: none; }
.step-num {
    width: 26px; height: 26px;
    border-radius: var(--radius-md);
    background: var(--accent-subtle);
    color: var(--accent);
    font-weight: 700;
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.step-text { color: var(--secondary); line-height: 1.4; }
.step-text strong { color: var(--foreground); }

/* ── Progress Bar ───────────────────────────────────────────────── */
.progress-container { display: none; margin-bottom: var(--space-6); }
.progress-container.visible { display: block; }
.progress-label {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--muted);
    margin-bottom: var(--space-2);
    display: flex;
    justify-content: space-between;
}
.progress-bar {
    height: 4px;
    background: var(--border);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 0.5s ease;
}
.progress-fill.indeterminate {
    width: 30%;
    animation: indeterminate 1.5s ease-in-out infinite;
}

/* ── Page Header ────────────────────────────────────────────────── */
.page-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-8);
}
.page-header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-4);
}
.page-title { font-size: var(--text-2xl); font-weight: 700; }
.page-subtitle { color: var(--muted); font-size: var(--text-md); margin-top: var(--space-1); }
.header-actions { display: flex; gap: var(--space-3); align-items: center; }

/* ── Summary Cards ──────────────────────────────────────────────── */
.summary-row {
    max-width: var(--max-width);
    margin: var(--space-4) auto;
    padding: 0 var(--space-8);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-3);
}
.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    border-left: 3px solid transparent;
}
.summary-label {
    font-size: var(--text-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.summary-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    margin-top: var(--space-1);
}
.summary-desc {
    font-size: var(--text-base);
    color: var(--muted);
    margin-top: var(--space-1);
}

/* ── Toast ──────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    background: var(--nav-bg);
    color: white;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-md);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateY(calc(100% + 4rem));
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: var(--z-toast);
    max-width: 400px;
    pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; pointer-events: auto; }
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }

/* ── Submit Bar ─────────────────────────────────────────────────── */
.submit-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: var(--space-3) var(--space-8);
    display: none;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    z-index: var(--z-submit-bar);
    box-shadow: 0 -2px 8px rgba(15, 23, 42, 0.04);
}
.submit-bar.visible { display: flex; }
.submit-summary { font-size: var(--text-md); color: var(--muted); }
.submit-summary strong { color: var(--foreground); }

/* ── Empty State ────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: var(--space-16) var(--space-8); color: var(--muted); }
.empty-state svg { margin-bottom: var(--space-4); opacity: 0.3; }
.empty-state h3 { font-size: var(--text-lg); margin-bottom: var(--space-2); color: var(--foreground); }

/* ── Submitted State ────────────────────────────────────────────── */
.submitted-banner {
    background: var(--success-bg);
    border: 1px solid var(--success);
    border-radius: var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    margin: var(--space-4) auto 0;
    max-width: var(--max-width);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    font-size: var(--text-md);
    font-weight: 600;
    color: var(--success);
}
.submitted-banner svg { flex-shrink: 0; }

/* ── View Toggle ────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ── Utility ────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Animations ─────────────────────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes indeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .summary-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
    .nav { padding: 0 var(--space-4); }
    .nav-user { display: none; }
    .summary-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .page-header { padding: var(--space-4); }
    .summary-row { padding: 0 var(--space-4); }
}
