/* ============================================================
   static/style.css — SkilLnk design tokens & base styles
   ------------------------------------------------------------
   THEMING MODEL
   - Light/dark:   <html data-theme="light|dark">  (set by boot
                    script in app.html; follows system unless the
                    user picks one via the theme toggle)
   - Role accent:  <html data-role="worker|recruiter|admin">
                    worker & recruiter share one accent for now;
                    admin has its own.
   Components must use these variables — never raw hex values.
   ============================================================ */

/* ---------- 1. Static scales (theme-independent) ---------- */
:root {
    /* Fonts */
    --font-body: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-heading: "Poppins", var(--font-body);

    /* Type scale */
    --text-xs: 12px;
    --text-sm: 13px;
    --text-base: 14px;
    --text-md: 15px;
    --text-lg: 17px;
    --text-xl: 20px;
    --text-2xl: 24px;
    --text-3xl: 28px;

    /* Spacing */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --spacing-2xl: 48px;

    /* Border radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Motion */
    --transition-default: all .24s cubic-bezier(.23, 1, .32, 1);
    --transition-fast: all .15s ease;

    /* Status colors (same in both themes) */
    --success: #22a94d;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --success-bg: rgba(34, 169, 77, 0.12);
    --warning-bg: rgba(245, 158, 11, 0.14);
    --error-bg: rgba(239, 68, 68, 0.12);
    --info-bg: rgba(59, 130, 246, 0.12);

    /* Text that sits on an accent-colored background */
    --text-on-primary: #ffffff;

    /* Layout */
    --header-height: 64px;
    --content-max-width: 1400px;
    /* Worker mobile fixed bottom-nav (WorkerHeader.svelte .bottom-nav) — used to pad
       page content so the last item isn't hidden underneath it. */
    --bottom-nav-height: 76px;
}

/* ---------- 2. Light theme (default) ---------- */
:root,
[data-theme="light"] {
    color-scheme: light;

    --bg-page: #eef2f7;        /* app background */
    --bg-card: #ffffff;        /* cards, panels, headers */
    --bg-subtle: #f4f7fb;      /* inputs, table stripes, hover wells */
    --bg-elevated: #ffffff;    /* dropdowns, modals */
    --bg-inset: #e6ebf2;       /* pressed / recessed areas */

    --text-primary: #101828;
    --text-secondary: #475467;
    --text-muted: #8a94a6;

    --border-light: rgba(16, 24, 40, 0.12);
    --border-lighter: rgba(16, 24, 40, 0.06);

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow-md: 0 4px 10px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 10px 24px rgba(16, 24, 40, 0.12);
    --shadow-xl: 0 20px 40px rgba(16, 24, 40, 0.16);

    --scrim: rgba(16, 24, 40, 0.45);   /* modal overlays */

    /* Custom dropdown chevron for <select> (muted grey) */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ---------- 3. Dark theme (standard neutral dark) ---------- */
[data-theme="dark"] {
    color-scheme: dark;

    --bg-page: #121212;
    --bg-card: #1e1e1e;
    --bg-subtle: #26262a;
    --bg-elevated: #2c2c30;
    --bg-inset: #0a0a0b;

    --text-primary: #f4f4f5;
    --text-secondary: #b0b6bf;
    --text-muted: #7d838d;

    --border-light: rgba(255, 255, 255, 0.12);
    --border-lighter: rgba(255, 255, 255, 0.06);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 10px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.5);

    --scrim: rgba(0, 0, 0, 0.6);

    /* Custom dropdown chevron for <select> (lighter for dark surfaces) */
    --select-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b0b6bf' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ---------- 4. Role accents ---------- */
/* Worker & recruiter share the SkilLnk cyan for now. */
:root,
[data-role="worker"],
[data-role="recruiter"] {
    --theme-primary: #0891b2;
    --theme-primary-dark: #0e7490;
    --theme-primary-light: #22d3ee;
    /* CTA gradient — brand cyan, deep enough for white label text.
       Used by .btn-primary and bespoke CTAs across pages. */
    --theme-gradient-start: #0891b2;
    --theme-gradient-end: #0e7490;
    --theme-bg-light: rgba(8, 145, 178, 0.10);
    --theme-bg-hover: rgba(8, 145, 178, 0.09);
    --theme-bg-active: rgba(8, 145, 178, 0.16);
    --theme-shadow: rgba(8, 145, 178, 0.30);
    --theme-border: rgba(8, 145, 178, 0.30);
}

/* Dark mode brightens the accent (SkilLnk logo cyan) so text,
   buttons and active states stay legible on neutral dark. */
[data-theme="dark"] {
    --theme-primary: #22d3ee;
    --theme-primary-dark: #0891b2;
    --theme-primary-light: #67e8f9;
    --theme-gradient-start: #0e7490;
    --theme-gradient-end: #0891b2;
    --theme-bg-light: rgba(34, 211, 238, 0.12);
    --theme-bg-hover: rgba(34, 211, 238, 0.10);
    --theme-bg-active: rgba(34, 211, 238, 0.20);
    --theme-shadow: rgba(34, 211, 238, 0.28);
    --theme-border: rgba(34, 211, 238, 0.36);
}

[data-role="admin"] {
    --theme-primary: #d32f2f;
    --theme-primary-dark: #b71c1c;
    --theme-primary-light: #ef5350;
    --theme-gradient-start: #5f1010;
    --theme-gradient-end: #b71c1c;
    --theme-bg-light: rgba(211, 47, 47, 0.10);
    --theme-bg-hover: rgba(211, 47, 47, 0.08);
    --theme-bg-active: rgba(211, 47, 47, 0.16);
    --theme-shadow: rgba(211, 47, 47, 0.22);
    --theme-border: rgba(211, 47, 47, 0.30);
}

[data-theme="dark"][data-role="admin"] {
    --theme-primary: #ef5350;
    --theme-primary-dark: #d32f2f;
    --theme-primary-light: #ff8a80;
    --theme-bg-light: rgba(239, 83, 80, 0.12);
    --theme-bg-hover: rgba(239, 83, 80, 0.09);
    --theme-bg-active: rgba(239, 83, 80, 0.18);
    --theme-shadow: rgba(239, 83, 80, 0.20);
    --theme-border: rgba(239, 83, 80, 0.32);
}

/* ---------- 5. Legacy aliases (do not use in new code) ---------- */
:root {
    --bg-white: var(--bg-card);
    --bg-light: var(--bg-subtle);
    --bg-lighter: var(--bg-elevated);
    --bg-dark: var(--bg-page);
    --bg-dark-card: var(--bg-card);
    --theme-body-bg: var(--bg-page);
}

/* ---------- 6. Reset & base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: var(--font-body);
    font-size: var(--text-base);
    -webkit-font-smoothing: antialiased;
    color: var(--text-secondary);
}

body {
    overflow-y: auto;
    background: var(--bg-page);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* App logo (navy artwork) — flip lightness in dark mode so the
   navy parts stay visible; hue-rotate keeps the cyan cyan. */
[data-theme="dark"] .logo img {
    filter: invert(1) hue-rotate(180deg) saturate(1.2);
}

/* ---------- 7. Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.3;
    margin: 0 0 var(--spacing-sm);
}

h1 { font-size: var(--text-3xl); font-weight: 700; }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p, li, article, table {
    font-family: var(--font-body);
    color: var(--text-secondary);
    margin: 0 0 var(--spacing-sm);
    line-height: 1.55;
}

a {
    text-decoration: none;
    color: inherit;
}

.link-primary {
    color: var(--theme-primary);
    cursor: pointer;
    transition: color 0.2s ease;
}

.link-primary:hover {
    color: var(--theme-primary-dark);
}

/* ---------- 8. Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--theme-primary);
    color: var(--text-on-primary);
    border: 1px solid var(--theme-primary);
    box-shadow: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-base);
    letter-spacing: 0.01em;
    line-height: 1.5;
    padding: 10px 24px;
    white-space: nowrap;
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: background-color .18s ease, border-color .18s ease,
                transform .18s ease, box-shadow .18s ease;
}

.btn:hover,
.btn.active {
    background: var(--theme-primary-dark);
    border-color: var(--theme-primary-dark);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--theme-bg-active);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Primary CTA — vibrant brand-cyan fill, visible in both themes */
.btn-primary,
.button-primary,
.submit-btn {
    background: linear-gradient(135deg, var(--theme-gradient-start), var(--theme-gradient-end));
    border: none;
    color: #ffffff;
}

.btn-primary:hover:not(:disabled),
.button-primary:hover:not(:disabled),
.submit-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--theme-primary-light), var(--theme-primary));
    transform: translateY(-1px);
    box-shadow: 0 6px 18px var(--theme-shadow);
}

.btn-primary:active:not(:disabled),
.button-primary:active:not(:disabled),
.submit-btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--theme-border);
    color: var(--theme-primary);
    box-shadow: none;
}

.btn-outline:hover {
    background: var(--theme-bg-hover);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--text-secondary);
    box-shadow: none;
}

.btn-ghost:hover {
    background: var(--theme-bg-hover);
    border-color: transparent;
    color: var(--theme-primary);
    box-shadow: none;
}

/* Follow / following toggle */
.btn.follow {
    min-width: 96px;
}

.btn.following {
    background: var(--bg-card);
    color: var(--theme-primary-dark);
    border: 1px solid var(--theme-primary);
    box-shadow: none;
    min-width: 96px;
}

.btn.following:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

/* ---------- 9. Badges ---------- */
.badge-primary,
.badge-success,
.badge-warning,
.badge-error {
    display: inline-block;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: 1.5;
}

.badge-primary { background: var(--theme-bg-active); color: var(--theme-primary); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-error   { background: var(--error-bg);   color: var(--error); }

/* ---------- 10. Forms ---------- */
input, textarea, select {
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-base);
    transition: var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--theme-primary);
    /* Use background-COLOR, not the `background` shorthand — the shorthand would
       reset background-repeat/position/size and make the <select> chevron tile. */
    background-color: var(--bg-card);
    box-shadow: 0 0 0 3px var(--theme-bg-light);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

/* Modern <select> — custom chevron, soft depth, animated micro-interactions */
select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 11px 44px 11px 16px;
    font-weight: 500;
    border-radius: var(--radius-md);
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 15px;
    background-color: var(--bg-subtle);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    line-height: 1.4;
    text-overflow: ellipsis;
    transition: border-color 0.18s ease, box-shadow 0.18s ease,
                background-color 0.18s ease, background-position 0.2s ease;
}

/* Subtle lift + chevron nudge on hover */
select:hover:not(:disabled):not(:focus) {
    border-color: var(--theme-border);
    background-color: var(--bg-card);
    background-position: right 13px center;
    box-shadow: var(--shadow-md);
}

/* Keep the single custom chevron (not the OS one) on focus + a soft themed ring.
   Re-assert the background props defensively so no shorthand elsewhere can make
   the arrow tile/repeat. */
select:focus {
    background-image: var(--select-arrow);
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 15px;
    box-shadow: 0 0 0 3px var(--theme-bg-light), var(--shadow-md);
}

select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

/* Dropdown list items — themed so dark mode isn't a white list */
select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 10px 12px;
    font-weight: 500;
}

select option:checked {
    background: var(--theme-bg-light);
    color: var(--theme-primary);
    font-weight: 600;
}

/* Multi-select / list boxes: no chevron, normal padding, flat (no lift) */
select[multiple],
select[size]:not([size="1"]) {
    background-image: none;
    padding: 8px;
    box-shadow: var(--shadow-sm);
    cursor: default;
}

select[multiple] option,
select[size]:not([size="1"]) option {
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
}

/* Remove the dotted focus ring in Firefox */
select:-moz-focusring {
    color: transparent;
    text-shadow: 0 0 0 var(--text-primary);
}

label {
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
}

/* ---------- 11. Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--spacing-lg);
    border: 1px solid var(--border-lighter);
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.cover-preview {
    background: linear-gradient(135deg, var(--theme-gradient-start) 0%, var(--theme-gradient-end) 100%);
}

/* ---------- 12. Utilities ---------- */
.full-width { width: 100% !important; max-width: none !important; flex: 0 0 100% !important; }
.display-none { display: none !important; }
.hide { visibility: hidden; opacity: 0; }
.show { visibility: visible; opacity: 1; }

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--theme-primary); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-warning { color: var(--warning); }

.flex { display: flex; }
.flex-column { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

.m-0 { margin: 0; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }
.mt-sm { margin-top: var(--spacing-sm); }
.mb-sm { margin-bottom: var(--spacing-sm); }
.ml-sm { margin-left: var(--spacing-sm); }
.mr-sm { margin-right: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mb-md { margin-bottom: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mb-lg { margin-bottom: var(--spacing-lg); }

.p-0 { padding: 0; }
.pt-0 { padding-top: 0; }
.pb-0 { padding-bottom: 0; }
.p-sm { padding: var(--spacing-sm); }
.p-md { padding: var(--spacing-md); }
.p-lg { padding: var(--spacing-lg); }

/* ---------- 13. Animations ---------- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ---------- 14. Spinner ---------- */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--theme-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 20px; height: 20px; border-width: 2px; }
.spinner-lg { width: 60px; height: 60px; border-width: 4px; }

/* ---------- 15. Toasts ---------- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    background: var(--bg-elevated);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: fadeIn 0.3s ease;
    border-left: 4px solid var(--theme-primary);
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--error); }
.toast-warning { border-left-color: var(--warning); }

/* ---------- 16. Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- 17. Responsive ---------- */
@media (max-width: 768px) {
    h1 { font-size: var(--text-2xl); }
    h2 { font-size: var(--text-xl); }
    h3 { font-size: var(--text-lg); }

    .card {
        padding: var(--spacing-md);
        border-radius: var(--radius-md);
    }

    .btn {
        padding: 8px 18px;
    }
}

/* ---------- 18. Print ---------- */
@media print {
    .no-print { display: none; }

    body {
        background: white;
        color: black;
    }
}
