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

/* ============================================================
   CSS Custom Properties: Light & Dark Theme
   ============================================================ */
:root {
    --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: #9ca3af;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --backdrop-color: rgba(107, 114, 128, 0.75);
    --scrollbar-thumb: #d1d5db;
    --scrollbar-thumb-hover: #9ca3af;
}

.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; }
.shadow-theme  { box-shadow: 0 1px 3px var(--shadow-color) !important; }

/* 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;
}

/* 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;
}
