/* ====== Base Styles ====== */
:root {
    --color-bg-start: #f8fafc;
    --color-bg-end: #e0e7ff;
    --color-surface: rgba(255,255,255,0.7);
    --color-surface-strong: rgba(255,255,255,0.85);
    --color-text-primary: #0f172a;
    --color-text-secondary: #64748b;
    --color-primary: #6366f1;
    --color-primary-700: #4338ca;
    --color-primary-900: #3730a3;
    --color-accent: #38bdf8;
    --color-success: #16a34a;
    --shadow-lg: 0 8px 32px rgba(60,72,88,0.18);
    --radius-lg: 1.5rem;
    --radius-md: 0.75rem;
}

/* Ensure padding/border are included in width calculations */
*, *::before, *::after {
    box-sizing: border-box;
}
body {
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--color-bg-start) 0%, var(--color-bg-end) 100%);
    margin: 0;
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
}

/* Global focus style for accessibility */
:where(a, button, input, textarea, [tabindex]):focus-visible {
    outline: 3px solid rgba(99,102,241,0.35);
    outline-offset: 2px;
    border-radius: 10px;
}

::selection {
    background: rgba(99,102,241,0.2);
}

/* ====== Hero Background Animation ====== */
.hero-bg {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 0;
    pointer-events: none;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.18;
    animation: float 8s ease-in-out infinite alternate;
}

.shape1 { width: 220px; height: 220px; background: #6366f1; top: 5%; left: 10%; animation-delay: 0s; }
.shape2 { width: 160px; height: 160px; background: #f59e42; top: 60%; left: 70%; animation-delay: 2s; }
.shape3 { width: 120px; height: 120px; background: #38bdf8; top: 80%; left: 20%; animation-delay: 4s; }

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(-30px) scale(1.08); }
}

/* ====== Main Container ====== */
.container {
    background: var(--color-surface);
    backdrop-filter: blur(12px) saturate(1.2);
    padding: 2.5rem 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
}

/* Wider container for recruiter page */
.container.wide {
    max-width: 520px;
}

.logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 0.5rem auto;
    display: block;
    line-height: 0; /* remove baseline gaps that can misalign */
}
.logo svg { display: block; margin: 0 auto; width: 100%; height: 100%; }

h1 {
    color: var(--color-primary-900);
    margin-bottom: 0.5rem;
    font-size: 2.2rem;
    letter-spacing: -1px;
    font-weight: 700;
}

p {
    color: var(--color-text-secondary);
    margin-bottom: 0.5rem;
    font-size: 1.08rem;
    font-weight: 500;
}

.tagline {
    color: var(--color-text-secondary);
    margin-bottom: 2rem;
    font-size: 1.08rem;
    font-weight: 500;
}

/* ====== Navigation ====== */
.nav-links {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 10;
    padding: 0.35rem;
    background: var(--color-surface);
    backdrop-filter: blur(10px);
    border-radius: 999px;
    box-shadow: 0 6px 24px rgba(16,24,40,0.12);
    border: 1px solid rgba(99,102,241,0.08);
}

/* Prevent content from hiding under the floating nav */
/* Account for floating nav on larger screens and safe-area (iOS notch) */
body { padding-top: calc(4.5rem + env(safe-area-inset-top, 0px)); }

.nav-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    transition: all 0.2s;
}

.nav-link:hover {
    background: rgba(99,102,241,0.08);
    transform: translateY(-1px);
}

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

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 0;
    cursor: pointer;
    background: rgba(99,102,241,0.08);
    color: var(--color-primary);
    transition: transform 0.15s ease, background 0.2s ease;
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle svg { width: 18px; height: 18px; }
body.theme-dark .icon-sun { display: inline; }
body.theme-dark .icon-moon { display: none; }
body:not(.theme-dark) .icon-sun { display: none; }
body:not(.theme-dark) .icon-moon { display: inline; }

/* ====== Upload Form & Drop Area (Jobseeker Page) ====== */
.upload-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.file-input-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 220px;
    min-height: 220px;
    height: auto;
    max-width: 100%;
    max-height: none;
    margin: 0 auto 1rem auto;
    overflow: hidden;
}

.file-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: auto;
    min-height: 220px;
    min-width: 220px;
    max-width: 100%;
    max-height: none;
    background: #f1f5f9;
    border: 4px dashed var(--color-primary);
    border-radius: 2rem;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 1.25rem;
    cursor: pointer;
    transition: background 0.2s, border 0.2s, color 0.2s, box-shadow 0.2s;
    text-align: center;
    box-shadow: 0 2px 12px rgba(99,102,241,0.06);
    padding: 1.6rem 1.2rem 1.2rem 1.2rem;
    position: relative;
    z-index: 2;
    gap: 1.2rem;
    overflow: hidden;
}

.file-label.selected {
    background: #d1fae5;
    border: 4px dashed var(--color-success);
    color: var(--color-success);
    box-shadow: 0 4px 18px rgba(16,185,129,0.13);
}

.file-label:hover,
.file-label:focus,
.file-label.dragover {
    background: #e0e7ff;
    border-color: var(--color-primary-700);
    box-shadow: 0 4px 18px rgba(99,102,241,0.13);
}

.upload-icon {
    display: block;
    margin-bottom: 0.5rem;
    animation: upload-bounce 1.2s infinite alternate;
}

.upload-icon svg rect {
    fill: #e0e7ef; /* Icon background for more contrast */
}

@keyframes upload-bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-8px); }
}

#dropText {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
}

input[type="file"] {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0; top: 0;
    cursor: pointer;
    z-index: 3;
    margin: 0;
    padding: 0;
    border: none;
    appearance: none;
}

.file-name {
    margin-top: 1.2rem;
    color: #64748b;
    font-size: 1.05rem;
    font-style: italic;
    display: block;
    min-height: 1.2em;
}

.file-name.selected {
    color: #16a34a;
    font-weight: 700;
}

#checkIcon {
    font-size: 1.2em;
    vertical-align: middle;
}

/* ====== Form Styles (Recruiter Page) ====== */
.job-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

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

.form-label {
    color: #c7d2fe;
    font-weight: 700;
    font-size: 1rem;
}

.form-input {
    padding: 0.85rem 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 0.75rem;
    font-size: 1rem;
    font-family: inherit;
    background: #f8fafc;
    transition: all 0.2s;
    resize: none;
}

.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

.form-textarea {
    min-height: 160px;
    line-height: 1.6;
}

.form-textarea-medium {
    min-height: 100px;
    line-height: 1.6;
}

.field-description {
    color: #64748b;
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(99,102,241,0.05);
    border-radius: 0.5rem;
    border-left: 3px solid #6366f1;
}

/* ====== Button & Footer ====== */
button {
    background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    padding: 0.85rem 1.7rem;
    font-size: 1.08rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(99,102,241,0.10);
    transition: background 0.2s, transform 0.15s;
}

button:hover, button:focus {
    background: linear-gradient(90deg, var(--color-primary-700) 0%, #0ea5e9 100%);
    transform: translateY(-2px) scale(1.03);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ====== Success Message ====== */
.success-message {
    color: #065f46;
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.22);
    margin-top: 1.2rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    transition: opacity 0.35s ease, transform 0.35s ease;
    display: inline-block;
    pointer-events: none;
}

.success-message.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

footer {
    margin-top: 2.5rem;
    color: #a5b4fc;
    font-size: 0.95rem;
    text-align: center;
    z-index: 1;
}

/* ====== Loading Overlay ====== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.58);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(4px) saturate(1.1);
}

.loading-overlay[hidden] {
    display: none !important;
}

.loading-content {
    background: var(--color-surface-strong);
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid rgba(99,102,241,0.25);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: var(--color-text-primary);
    font-weight: 600;
}

/* ====== Stats Page Styles ====== */
.stats-container {
    width: 100%;
    max-width: 600px;
    margin: 2rem 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.stat-card {
    background: var(--color-surface-strong);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 100%;
    max-width: 400px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    transition: left 0.5s ease;
}

.stat-card:hover::before {
    left: 100%;
}

.stat-number {
    font-size: 4rem;
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
}

.stat-label {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
}

.stat-sublabel {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    opacity: 0.8;
}

.stat-meta {
    width: 100%;
    max-width: 400px;
}

.stat-info {
    background: var(--color-surface);
    backdrop-filter: blur(10px);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.info-item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.info-label {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    font-weight: 500;
}

.info-value {
    font-size: 0.875rem;
    color: var(--color-text-primary);
    font-weight: 600;
}

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

.loading-spinner .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-left-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.error-message {
    background: rgba(220, 38, 38, 0.1);
    color: #dc2626;
    padding: 1rem;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.error-detail {
    font-size: 0.75rem;
    margin-top: 0.5rem;
    opacity: 0.8;
}

.refresh-button-container {
    margin-top: 1rem;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-surface);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--color-text-primary);
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.refresh-btn:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.refresh-btn svg {
    transition: transform 0.2s ease;
}

.refresh-btn:hover:not(:disabled) svg {
    transform: rotate(180deg);
}

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

/* ====== Dark Theme Overrides ====== */
body.theme-dark {
    --color-bg-start: #0b1220;
    --color-bg-end: #111827;
    --color-surface: rgba(17,24,39,0.6);
    --color-surface-strong: rgba(17,24,39,0.8);
    --color-text-primary: #e5e7eb;
    --color-text-secondary: #94a3b8;
}

body.theme-dark .container {
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}
body.theme-dark h1 { color: #c7d2fe; }
body.theme-dark p,
body.theme-dark .tagline { color: var(--color-text-secondary); }
body.theme-dark .nav-links {
    border-color: rgba(99,102,241,0.18);
}
body.theme-dark .nav-link { color: #c7d2fe; }
body.theme-dark .file-label {
    background: #0b1220;
    border-color: var(--color-primary-700);
    color: #c7d2fe;
}
body.theme-dark .form-input {
    background: #0b1220;
    color: var(--color-text-primary);
    border-color: #1f2937;
}
body.theme-dark .field-description {
    background: rgba(99,102,241,0.12);
    color: var(--color-text-secondary);
}
body.theme-dark .success-message {
    color: #bbf7d0;
    background: rgba(16,185,129,0.18);
    border-color: rgba(16,185,129,0.32);
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    .shape,
    .upload-icon,
    .nav-link,
    .theme-toggle,
    .success-message {
        animation: none !important;
        transition: none !important;
    }
}

/* ====== Responsive Styles ====== */
@media (max-width: 600px) {
    body { 
        padding-top: calc(4rem + env(safe-area-inset-top, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        justify-content: flex-start;
        align-items: center;
    }
    .container {
        padding: 1.25rem 1rem;
        max-width: 92vw;
        border-radius: 1rem;
        margin: 0 auto 1rem auto;
    }
    
    .container.wide {
        padding: 1.5rem 1rem;
        max-width: 95vw;
    }
    
    h1 {
        font-size: 1.4rem;
        line-height: 1.25;
        margin-top: 0.25rem;
    }
    p, .tagline { font-size: 0.98rem; }
    
    .container.wide h1 {
        font-size: 1.8rem;
    }
    
    .logo {
        width: 48px;
        height: 48px;
    }
    
    .container.wide .logo {
        width: 48px;
        height: 48px;
    }
    
    .nav-links {
        position: fixed;
        top: calc(0.5rem + env(safe-area-inset-top, 0px));
        left: 50%;
        transform: translateX(-50%);
        justify-content: center;
        margin-bottom: 0;
        flex-wrap: nowrap;
        padding: 0.25rem 0.3rem;
        backdrop-filter: blur(12px) saturate(1.2);
    }
    
    .nav-link {
        font-size: 0.8rem;
        padding: 0.4rem 0.8rem;
    }

    /* no theme toggle on mobile */
    
    /* Jobseeker page mobile styles */
    .file-label, .file-input-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 150px;
        height: auto;
        font-size: 1rem;
        border-radius: 1.2rem;
        padding: 1.1rem 0.75rem 1rem 0.75rem;
    }
    .file-label { gap: 0.6rem; }

    /* Improve touch targets for inputs on mobile */
    .form-input {
        padding: 1rem 1rem;
        font-size: 1.02rem;
    }
    
    .upload-icon svg {
        width: 32px;
        height: 32px;
    }
    
    #dropText {
        font-size: 1rem;
    }
    
    .file-name {
        font-size: 0.95rem;
    }
    
    /* Recruiter page mobile styles */
    .form-textarea {
        min-height: 120px;
    }
    
    .form-textarea-medium {
        min-height: 80px;
    }
    
    button {
        font-size: 1rem;
        padding: 0.75rem 1.1rem;
    }

    /* Tone down and reposition background blobs so they don't crowd the navbar */
    .shape { opacity: 0.12; }
    .shape1 { width: 120px; height: 120px; top: 18%; left: 70%; }
    .shape2 { width: 100px; height: 100px; top: 70%; left: 12%; }
    .shape3 { width: 80px; height: 80px; top: 85%; left: 72%; }
}