/* app.css - Timesheet Inteligente theme & utilities */

/* ============================================================
   E1: Typography — body sans, page-title serif, tabular mono
   Fonts loaded via <link> in base.html/login.html (self-host: Onda C)
   ============================================================ */
body {
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
/* E5: subtle atmosphere — barely-there brand mesh fixed behind content.
   Static (reduced-motion-safe), dark-aware, pointer-events:none. Adds depth
   to the flat bg-page without competing with dense data. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(55rem 45rem at 100% -8%, rgba(37, 99, 235, 0.05), transparent 60%),
        radial-gradient(48rem 42rem at -8% 108%, rgba(96, 165, 250, 0.045), transparent 55%);
}
.dark body::before {
    background:
        radial-gradient(55rem 45rem at 100% -8%, rgba(96, 165, 250, 0.07), transparent 60%),
        radial-gradient(48rem 42rem at -8% 108%, rgba(37, 99, 235, 0.06), transparent 55%);
}
/* Page titles (h1) get the editorial serif; section/card titles stay sans */
h1 {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
}
/* Numeric/data faces use mono for alignment + character */
.font-num,
.kpi-value {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   CSS Custom Properties: Light & Dark Theme
   ============================================================ */
:root {
    /* Native controls (date/time pickers, selects, scrollbars) follow the theme.
       Without this, <input type="date"> renders its calendar-picker-indicator in
       light chrome — a dark icon on the dark .input-theme background = invisible/
       unclickable, so the date appears non-editable in dark mode. */
    color-scheme: light;

    /* E1: type system — Sóbrio premium (Spectral / Hanken Grotesk / Geist Mono) */
    --font-body: 'Hanken Grotesk', ui-sans-serif, system-ui, -apple-system, sans-serif;
    --font-display: 'Spectral', Georgia, 'Times New Roman', serif;
    --font-mono: 'Geist Mono', ui-monospace, 'SF Mono', 'Cascadia Code', monospace;

    /* E8: shared motion tokens — enter slower, exit faster, one easing */
    --ease-entrance: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-enter: 0.4s;
    --dur-exit: 0.25s;

    --bg-page: #f9fafb;
    --bg-surface: #ffffff;
    --bg-surface-alt: #f9fafb;
    --bg-muted: #f3f4f6;
    --border-default: #e5e7eb;
    --border-input: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #4b5563;
    --text-muted: #6b7280;
    --text-faint: #6b7280; /* A4: was #9ca3af (~2.5:1) — bumped to 4.5:1 AA on white/page */
    --shadow-color: rgba(0, 0, 0, 0.05);
    --backdrop-color: rgba(107, 114, 128, 0.75);
    --scrollbar-thumb: #d1d5db;
    --scrollbar-thumb-hover: #9ca3af;
}

.dark {
    color-scheme: dark;
    --bg-page: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-alt: #334155;
    --bg-muted: #334155;
    --border-default: #334155;
    --border-input: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #e2e8f0;
    --text-tertiary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --backdrop-color: rgba(0, 0, 0, 0.75);
    --scrollbar-thumb: #475569;
    --scrollbar-thumb-hover: #64748b;
}

/* ============================================================
   Semantic Utility Classes
   ============================================================ */
.bg-page       { background-color: var(--bg-page) !important; }
.bg-surface    { background-color: var(--bg-surface) !important; }
.bg-surface-alt { background-color: var(--bg-surface-alt) !important; }
.bg-muted-theme { background-color: var(--bg-muted) !important; }
.border-theme  { border-color: var(--border-default) !important; }
.border-input-theme { border-color: var(--border-input) !important; }
.text-primary  { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-tertiary { color: var(--text-tertiary) !important; }
.text-muted-theme { color: var(--text-muted) !important; }
.text-faint    { color: var(--text-faint) !important; }
/* E7: elevation scale — resting card / dropdown / modal.
   shadow-theme = card resting (two-layer for real depth). */
.shadow-theme  { box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 6px var(--shadow-color) !important; }
.shadow-elev-1 { box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 6px var(--shadow-color) !important; }
.shadow-elev-2 { box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 8px 20px var(--shadow-color) !important; }
.shadow-elev-3 { box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 16px 40px var(--shadow-color) !important; }

/* Subtle hover lift for cards (gated by reduced-motion below) */
.chart-card,
.kpi-card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.chart-card:hover,
.kpi-card:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.06), 0 8px 20px var(--shadow-color);
    transform: translateY(-2px);
}

/* Input fields: background + border + text */
.input-theme {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-input) !important;
    color: var(--text-primary) !important;
}

/* Hover for table rows and interactive surfaces */
.hover-surface:hover {
    background-color: var(--bg-surface-alt) !important;
}

/* Variants hover: dos tokens custom (revisão 2026-07-07, C — issue #249).
   Os templates usam hover:bg-surface-alt / hover:text-primary etc., mas esses
   tokens são do app.css (não são utilitários Tailwind) — sem estas regras,
   378+ usos eram no-op silencioso. Seletores com ":" escapado casam a classe
   literal que já está nos templates. */
.hover\:bg-surface-alt:hover { background-color: var(--bg-surface-alt) !important; }
.hover\:bg-muted-theme:hover { background-color: var(--bg-muted) !important; }
.hover\:text-primary:hover   { color: var(--text-primary) !important; }
.hover\:text-secondary:hover { color: var(--text-secondary) !important; }
.hover\:border-theme:hover   { border-color: var(--border-default) !important; }

/* Dividers */
.divide-theme > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--border-default) !important;
}

/* ============================================================
   Dark mode overrides for colored badges/backgrounds
   (uses rgba for transparency on dark backgrounds)
   ============================================================ */
.dark .bg-green-50   { background-color: rgba(34, 197, 94, 0.1) !important; }
.dark .bg-green-100  { background-color: rgba(34, 197, 94, 0.15) !important; }
.dark .bg-amber-50   { background-color: rgba(245, 158, 11, 0.1) !important; }
.dark .bg-amber-100  { background-color: rgba(245, 158, 11, 0.15) !important; }
.dark .bg-orange-50  { background-color: rgba(249, 115, 22, 0.1) !important; }
.dark .bg-orange-100 { background-color: rgba(249, 115, 22, 0.15) !important; }
.dark .bg-red-50     { background-color: rgba(239, 68, 68, 0.1) !important; }
.dark .bg-red-100    { background-color: rgba(239, 68, 68, 0.15) !important; }
.dark .bg-blue-50    { background-color: rgba(59, 130, 246, 0.1) !important; }
.dark .bg-blue-100   { background-color: rgba(59, 130, 246, 0.15) !important; }
.dark .bg-purple-50  { background-color: rgba(168, 85, 247, 0.1) !important; }
.dark .bg-purple-100 { background-color: rgba(168, 85, 247, 0.15) !important; }
.dark .bg-cyan-100   { background-color: rgba(6, 182, 212, 0.15) !important; }
.dark .bg-indigo-100 { background-color: rgba(99, 102, 241, 0.15) !important; }
.dark .bg-pink-100   { background-color: rgba(236, 72, 153, 0.15) !important; }
.dark .bg-emerald-100 { background-color: rgba(16, 185, 129, 0.15) !important; }
.dark .bg-stone-100  { background-color: rgba(120, 113, 108, 0.15) !important; }
.dark .bg-brand-50   { background-color: rgba(59, 130, 246, 0.1) !important; }
.dark .bg-brand-100  { background-color: rgba(59, 130, 246, 0.15) !important; }

/* Dark mode text for colored badges - slightly brighter */
.dark .text-green-700  { color: #4ade80 !important; }
.dark .text-green-800  { color: #86efac !important; }
.dark .text-amber-700  { color: #fbbf24 !important; }
.dark .text-amber-800  { color: #fcd34d !important; }
.dark .text-orange-700 { color: #fb923c !important; }
.dark .text-orange-800 { color: #fdba74 !important; }
.dark .text-red-700    { color: #f87171 !important; }
.dark .text-red-800    { color: #fca5a5 !important; }
.dark .text-purple-700 { color: #c084fc !important; }
.dark .text-purple-800 { color: #d8b4fe !important; }
.dark .text-blue-800   { color: #93c5fd !important; }
.dark .text-cyan-800   { color: #67e8f9 !important; }
.dark .text-indigo-800 { color: #a5b4fc !important; }
.dark .text-pink-800   { color: #f9a8d4 !important; }
.dark .text-emerald-800 { color: #6ee7b7 !important; }
.dark .text-stone-800  { color: #d6d3d1 !important; }

/* Dark overrides for green-50/30 row backgrounds used in tables */
.dark .bg-green-50\/30 { background-color: rgba(34, 197, 94, 0.05) !important; }
.dark .bg-green-50\/20 { background-color: rgba(34, 197, 94, 0.04) !important; }
.dark .bg-brand-50\/50 { background-color: rgba(59, 130, 246, 0.08) !important; }

/* Dark select/option fix */
.dark select,
.dark option {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

/* Dark file input */
.dark input[type="file"]::file-selector-button {
    background-color: rgba(59, 130, 246, 0.1);
    color: #93c5fd;
}

/* Dark placeholder text */
.dark ::placeholder {
    color: var(--text-faint) !important;
}

/* Dark checkbox/radio */
.dark input[type="checkbox"],
.dark input[type="radio"] {
    background-color: var(--bg-surface);
    border-color: var(--border-input);
}

/* ============================================================
   Alpine.js x-cloak
   ============================================================ */
[x-cloak] { display: none !important; }

/* ============================================================
   Print: force light mode
   ============================================================ */
@media print {
    :root {
        --bg-page: #ffffff;
        --bg-surface: #ffffff;
        --bg-surface-alt: #f9fafb;
        --bg-muted: #f3f4f6;
        --border-default: #e5e7eb;
        --border-input: #d1d5db;
        --text-primary: #111827;
        --text-secondary: #374151;
        --text-tertiary: #4b5563;
        --text-muted: #6b7280;
        --text-faint: #9ca3af;
    }
    nav, .no-print, button, select, input { display: none !important; }
    main { padding: 0 !important; }
    .shadow-sm, .shadow-theme { box-shadow: none !important; }
    table { font-size: 11px; }
}

/* ============================================================
   Calendar View (Agenda tab in Timesheet)
   ============================================================ */
.cal-block {
    position: absolute;
    left: 2px;
    right: 2px;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.7rem;
    line-height: 1.2;
    overflow: hidden;
    cursor: pointer;
    z-index: 2;
    border-left: 3px solid var(--cal-block-accent, #3b82f6);
    transition: box-shadow 0.15s, transform 0.1s;
}
.cal-block:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    transform: scale(1.01);
    z-index: 5;
}
.cal-block-local {
    background-color: rgba(59, 130, 246, 0.12);
    --cal-block-accent: #3b82f6;
}
.cal-block-glpi {
    background-color: rgba(249, 115, 22, 0.12);
    --cal-block-accent: #f97316;
}
.dark .cal-block-local {
    background-color: rgba(59, 130, 246, 0.2);
}
.dark .cal-block-glpi {
    background-color: rgba(249, 115, 22, 0.2);
}
/* Now-line in day/week view */
.cal-now-line {
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: #ef4444;
    z-index: 3;
    pointer-events: none;
}
.cal-now-line::before {
    content: '';
    position: absolute;
    left: -4px;
    top: -3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
}
/* Month view cells */
.cal-month-cell {
    min-height: 110px;
    border: 1px solid var(--border-default);
    padding: 4px 5px;
    cursor: pointer;
    transition: background-color 0.15s;
}
.cal-month-cell:hover {
    background-color: var(--bg-surface-alt);
}
.cal-month-cell.today {
    background-color: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.3);
}
.dark .cal-month-cell.today {
    background-color: rgba(59, 130, 246, 0.12);
}
.cal-month-cell.outside {
    opacity: 0.4;
}
.cal-month-cell.selected {
    box-shadow: inset 0 0 0 2px var(--brand-500, #3b82f6);
}
.cal-month-bar {
    height: 4px;
    border-radius: 2px;
    margin-bottom: 1px;
}
/* Month cell entry cards */
.cal-month-entry {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 2px 3px;
    margin-bottom: 2px;
    border-left: 3px solid var(--cal-entry-color, #3b82f6);
    border-radius: 2px;
    background: var(--bg-surface-alt, rgba(0,0,0,0.03));
    font-size: 0.6rem;
    line-height: 1.25;
    overflow: hidden;
    white-space: nowrap;
}
.dark .cal-month-entry {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.85);
}
/* Status badges */
.cal-status-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 2px;
}
.cal-status-dot.approved { background: #22c55e; }
.cal-status-dot.pending  { background: #9ca3af; border: 1px solid #6b7280; }
.cal-status-dot.rejected { background: #ef4444; }
/* Day detail sidebar */
.cal-sidebar {
    width: 320px;
    flex-shrink: 0;
    border-left: 1px solid var(--border-default);
    background: var(--bg-surface, #fff);
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    transition: width 0.2s ease, opacity 0.2s ease;
}
.dark .cal-sidebar {
    background: var(--bg-surface, #1e1e1e);
}
.cal-sidebar-entry {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    transition: background-color 0.12s;
}
.cal-sidebar-entry:hover {
    background-color: var(--bg-surface-alt);
}
.cal-sidebar-entry:last-child {
    border-bottom: none;
}
@media (max-width: 1023px) {
    .cal-sidebar {
        position: fixed;
        top: 0; right: 0; bottom: 0;
        z-index: 40;
        box-shadow: -4px 0 12px rgba(0,0,0,0.15);
    }
}

/* ============================================================
   Shared entrance animations
   ============================================================ */
@keyframes kpi-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes chart-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.8; }
}

.chart-card {
    animation: chart-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}

.skeleton-pulse {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* ============================================================
   Scrollbar
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ============================================================
   Transition for theme changes
   ============================================================ */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
}

/* ============================================================
   A1: Respect prefers-reduced-motion (WCAG)
   Neutralize all decorative motion: keyframe animations, looping
   background drift, hover lifts. Keep instant state changes usable.
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
    /* Infinite/looping decorative animations: stop entirely */
    .login-bg-blob,
    .status-dot-online,
    .skeleton-pulse,
    .kpi-skeleton-pulse {
        animation: none !important;
    }
    /* Hover lifts that translate */
    .nav-link:hover,
    .login-btn:hover:not(:disabled),
    .chart-card:hover,
    .kpi-card:hover {
        transform: none !important;
    }
}

/* ============================================================
   Arbitrary z-index utilities NOT emitted by the static Tailwind
   build (build:css predates these usages). Loaded after tailwind.css
   so they apply. Without these, `z-[60]`/`z-[100]` resolve to
   z-index:auto and the element falls behind z-40/z-50 modals:
   - z-[60]:  _requester_modal.html, _feedback_widget.html
   - z-[100]: base.html impersonation banner + skip-link
   ============================================================ */
.z-\[60\]  { z-index: 60; }
.z-\[100\] { z-index: 100; }
