/* =========================================================================
   Femidaprime / Arbitro — Design System
   Modern Fluent · Indigo accent · Light + Dark themes
   ========================================================================= */

/* ------------------------------- Tokens ---------------------------------- */

:root {
    /* Brand (indigo / violet) */
    --brand-50:  #eef2ff;
    --brand-100: #e0e7ff;
    --brand-300: #a5b4fc;
    --brand-500: #6366f1;
    --brand-600: #4f46e5;
    --brand-700: #4338ca;

    /* Semantic */
    --success:      #10b981;
    --success-soft: #ecfdf5;
    --danger:       #f43f5e;
    --danger-soft:  #fff1f2;
    --warning:      #f59e0b;

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-pill: 999px;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 1px rgba(15, 23, 42, 0.02);
    --shadow-md: 0 6px 16px rgba(15, 23, 42, 0.06), 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10), 0 4px 12px rgba(15, 23, 42, 0.06);

    /* Motion */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --dur-fast: 120ms;
    --dur: 200ms;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Light theme palette */
[data-bs-theme="light"] {
    --bg-app: #f8fafc;
    --bg-gradient:
        radial-gradient(1200px 600px at 50% -200px, rgba(165, 180, 252, 0.35) 0%, transparent 60%),
        radial-gradient(800px 500px at 110% 0%, rgba(196, 181, 253, 0.25) 0%, transparent 55%),
        #f8fafc;
    --bg-card: #ffffff;
    --bg-header: rgba(255, 255, 255, 0.72);
    --bg-input: #ffffff;
    --bg-ghost-hover: rgba(15, 23, 42, 0.04);

    --text-primary:   #0f172a;
    --text-secondary: #334155;
    --text-muted:     #64748b;

    --border-subtle: #e2e8f0;
    --border-strong: #cbd5e1;

    --focus-ring: rgba(99, 102, 241, 0.22);
    --card-border: 1px solid var(--border-subtle);
}

/* Dark theme palette */
[data-bs-theme="dark"] {
    --bg-app: #0b1020;
    --bg-gradient:
        radial-gradient(1200px 700px at 50% -220px, rgba(99, 102, 241, 0.22) 0%, transparent 55%),
        radial-gradient(900px 500px at 100% 0%, rgba(139, 92, 246, 0.18) 0%, transparent 60%),
        #0b1020;
    --bg-card: #111827;
    --bg-header: rgba(15, 20, 38, 0.65);
    --bg-input: #1f2937;
    --bg-ghost-hover: rgba(255, 255, 255, 0.06);

    --text-primary:   #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted:     #94a3b8;

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);

    --focus-ring: rgba(129, 140, 248, 0.40);
    --card-border: 1px solid var(--border-subtle);
}

/* -------------------------------- Base ----------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    margin: 0;
    font-feature-settings: 'cv11', 'ss01';
    letter-spacing: -0.005em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--brand-600); text-decoration: none; transition: color var(--dur) var(--ease); }
a:hover { color: var(--brand-700); }
[data-bs-theme="dark"] a { color: var(--brand-300); }
[data-bs-theme="dark"] a:hover { color: #c7d2fe; }

/* ------------------------------- Header ---------------------------------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    background-color: var(--bg-header);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border-subtle);
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    transition: opacity var(--dur) var(--ease);
}
.app-brand:hover { opacity: 0.85; color: var(--text-primary); }

.app-brand__logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    border-radius: var(--r-sm);
}

.app-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* User badge */

.app-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--brand-700);
    background: var(--brand-50);
    border: 1px solid var(--brand-100);
    border-radius: var(--r-pill);
    line-height: 1;
}
.app-badge__admin {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    color: var(--brand-600);
    opacity: 0.8;
}
[data-bs-theme="dark"] .app-badge {
    color: var(--brand-300);
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.24);
}
[data-bs-theme="dark"] .app-badge__admin { color: var(--brand-300); opacity: 0.9; }

/* ------------------------------ Layout ----------------------------------- */

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

.app-main {
    flex: 1;
    display: flex;
    justify-content: center;
    padding: 48px 20px 80px;
}

.app-container {
    width: 100%;
    max-width: 560px;
}

/* -------------------------------- Card ----------------------------------- */

.app-card {
    background: var(--bg-card);
    border-radius: var(--r-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: var(--card-border);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient highlight on card top in dark theme */
[data-bs-theme="dark"] .app-card::before {
    content: '';
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(165, 180, 252, 0.35), transparent);
}

.app-card__title {
    margin: 0 0 8px;
    font-size: 1.375rem;
    font-weight: 600;
    letter-spacing: -0.015em;
    text-align: center;
    color: var(--text-primary);
}

.app-card__subtitle {
    margin: 0 0 28px;
    font-size: 0.925rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}

.app-card__subtitle .highlight {
    font-weight: 600;
    color: var(--text-secondary);
}

/* ---------------------------- Form primitives ---------------------------- */

.form-field {
    margin-bottom: 18px;
}

.form-field__label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-control,
.form-select {
    display: block;
    width: 100%;
    padding: 11px 14px;
    font-size: 0.95rem;
    font-family: var(--font-sans);
    color: var(--text-primary);
    background-color: var(--bg-input);
    border: 1px solid var(--border-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    transition:
        border-color var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease),
        background-color var(--dur) var(--ease);
    appearance: none;
    -webkit-appearance: none;
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

.form-control:focus,
.form-select:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px var(--focus-ring);
}

.form-control:disabled,
.form-select:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Select arrow (inherits across themes) */
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px;
}
[data-bs-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3e%3cpath stroke-linecap='round' stroke-linejoin='round' d='m6 9 6 6 6-6'/%3e%3c/svg%3e");
}

/* Dates */
input[type="date"].form-control {
    max-width: 220px;
}

.form-text {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.45;
}

/* Input group for password */
.input-group {
    position: relative;
    display: flex;
    align-items: stretch;
}
.input-group > .form-control {
    padding-right: 48px;
}
.input-group__action {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: transparent;
    border: 0;
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.input-group__action:hover {
    background: var(--bg-ghost-hover);
    color: var(--text-secondary);
}
.input-group__action:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* Checkbox */
.form-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}
.form-check-input {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--border-strong);
    border-radius: 5px;
    background: var(--bg-input);
    cursor: pointer;
    transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
    position: relative;
    flex-shrink: 0;
}
.form-check-input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
    border-color: var(--brand-500);
}
.form-check-input:checked {
    background: var(--brand-600);
    border-color: var(--brand-600);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='white'%3e%3cpath d='M12.207 4.793a1 1 0 0 1 0 1.414l-5 5a1 1 0 0 1-1.414 0l-2-2a1 1 0 1 1 1.414-1.414L6.5 9.086l4.293-4.293a1 1 0 0 1 1.414 0z'/%3e%3c/svg%3e");
    background-size: 14px;
    background-position: center;
    background-repeat: no-repeat;
}
.form-check-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Row for "current date" + date input */
.form-row-inline {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.form-row-inline > :first-child { flex-shrink: 0; }
.form-row-inline > :last-child { flex: 1; min-width: 180px; }

/* -------------------------------- Buttons -------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-family: var(--font-sans);
    font-size: 0.925rem;
    font-weight: 500;
    line-height: 1.2;
    border-radius: var(--r-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition:
        transform var(--dur-fast) var(--ease),
        background-color var(--dur) var(--ease),
        color var(--dur) var(--ease),
        border-color var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus-ring);
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none !important; }

/* Primary — gradient */
.btn-primary {
    color: #ffffff;
    background: linear-gradient(135deg, var(--brand-500) 0%, var(--brand-600) 100%);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.25), 0 2px 4px rgba(79, 70, 229, 0.15);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(79, 70, 229, 0.32), 0 4px 8px rgba(79, 70, 229, 0.18);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

/* Success — gradient (for "download" and submit) */
.btn-success {
    color: #ffffff;
    background: linear-gradient(135deg, #34d399 0%, var(--success) 100%);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.25), 0 2px 4px rgba(16, 185, 129, 0.15);
}
.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(16, 185, 129, 0.32), 0 4px 8px rgba(16, 185, 129, 0.18);
}
.btn-success:active:not(:disabled) { transform: translateY(0); }

/* Outline-success — for download links in result block */
.btn-outline-success {
    color: var(--success);
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, 0.35);
}
.btn-outline-success:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.15);
    border-color: var(--success);
    transform: translateY(-1px);
}
[data-bs-theme="dark"] .btn-outline-success {
    color: #6ee7b7;
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.28);
}
[data-bs-theme="dark"] .btn-outline-success:hover:not(:disabled) {
    background: rgba(16, 185, 129, 0.18);
    border-color: #34d399;
}

/* Ghost — for header actions */
.btn-ghost {
    color: var(--text-secondary);
    background: transparent;
    border-color: var(--border-subtle);
    padding: 8px 14px;
    font-size: 0.875rem;
}
.btn-ghost:hover:not(:disabled) {
    background: var(--bg-ghost-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

/* Danger ghost — for logout */
.btn-ghost-danger {
    color: var(--danger);
    background: transparent;
    border-color: transparent;
    padding: 8px 14px;
    font-size: 0.875rem;
}
.btn-ghost-danger:hover:not(:disabled) {
    background: var(--danger-soft);
    border-color: rgba(244, 63, 94, 0.25);
}
[data-bs-theme="dark"] .btn-ghost-danger {
    color: #fb7185;
}
[data-bs-theme="dark"] .btn-ghost-danger:hover:not(:disabled) {
    background: rgba(244, 63, 94, 0.12);
    border-color: rgba(244, 63, 94, 0.28);
}

/* Icon-only button (theme toggle) */
.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    color: var(--text-secondary);
    background: transparent;
    border-color: var(--border-subtle);
}
.btn-icon:hover:not(:disabled) {
    background: var(--bg-ghost-hover);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-icon svg { width: 18px; height: 18px; }

/* Submit row */
.form-submit-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 8px;
}

/* ------------------------------ Spinner ---------------------------------- */

.spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(99, 102, 241, 0.18);
    border-top-color: var(--brand-600);
    border-radius: 50%;
    animation: spinner-rotate 0.8s linear infinite;
}
.spinner.is-visible { display: inline-block; }

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

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 2s; }
    .btn:hover { transform: none !important; }
}

/* ------------------------------- Alerts ---------------------------------- */

.alert {
    border-radius: var(--r-md);
    padding: 12px 16px;
    font-size: 0.9rem;
    margin: 0;
    border: 1px solid transparent;
    border-left-width: 3px;
    line-height: 1.5;
}

.alert-success {
    color: #065f46;
    background: var(--success-soft);
    border-color: rgba(16, 185, 129, 0.25);
    border-left-color: var(--success);
}
.alert-danger {
    color: #9f1239;
    background: var(--danger-soft);
    border-color: rgba(244, 63, 94, 0.25);
    border-left-color: var(--danger);
}
[data-bs-theme="dark"] .alert-success {
    color: #a7f3d0;
    background: rgba(16, 185, 129, 0.10);
    border-color: rgba(16, 185, 129, 0.25);
    border-left-color: #34d399;
}
[data-bs-theme="dark"] .alert-danger {
    color: #fecdd3;
    background: rgba(244, 63, 94, 0.10);
    border-color: rgba(244, 63, 94, 0.25);
    border-left-color: #fb7185;
}

/* Legacy error/hint classes kept for template compatibility */
.error {
    color: var(--danger);
    margin-top: 12px;
    font-size: 0.9rem;
}
[data-bs-theme="dark"] .error { color: #fb7185; }

.hint {
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ---------------------------- Result block ------------------------------- */

.result-block {
    display: none;
    margin-top: 28px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}
.result-block.is-visible { display: block; }

.result-block__buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}
.result-block__buttons .btn { width: 100%; }

/* --------------------------- Theme toggle icons -------------------------- */

/* Show sun on dark (to switch TO light), moon on light (to switch TO dark) */
.theme-toggle__sun  { display: none; }
.theme-toggle__moon { display: inline-block; }

[data-bs-theme="dark"] .theme-toggle__sun  { display: inline-block; }
[data-bs-theme="dark"] .theme-toggle__moon { display: none; }

/* ----------------------------- Accessibility ----------------------------- */

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

::selection {
    background: rgba(99, 102, 241, 0.25);
    color: var(--text-primary);
}

/* ----------------------------- Responsive -------------------------------- */

@media (max-width: 640px) {
    .app-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .app-brand__logo { width: 32px; height: 32px; }
    .app-main { padding: 28px 16px 56px; }
    .app-card { padding: 24px 20px; border-radius: var(--r-md); }
    .app-card__title { font-size: 1.2rem; }
    .app-badge { display: none; }
    .btn-ghost, .btn-ghost-danger { padding: 6px 10px; font-size: 0.82rem; }
}
