/* ═══════════════════════════════════════════════════════════════
   Finança — Custom Styles
   Design: Binance-inspired flat surfaces, yellow accent, dual-theme
   ═══════════════════════════════════════════════════════════════ */

/* ─── Theme Tokens ───────────────────────────────────────────── */
:root,
html.dark {
    /* RGB triplets consumidos pelo Tailwind (dark-900..500) */
    --c-dark-900: 11 14 17;
    --c-dark-800: 30 35 41;
    --c-dark-700: 43 49 57;
    --c-dark-600: 43 49 57;
    --c-dark-500: 58 58 58;
    /* Tokens semânticos dos componentes */
    --surface: #1e2329;
    --surface-2: #0b0e11;
    --surface-hover: #2b3139;
    --border: #2b3139;
    --border-hover: #3a3a3a;
    --text: #ffffff;
    --text-muted: rgba(156, 163, 175, 1);
    --hover-overlay: rgba(255, 255, 255, 0.05);
}

html.light {
    --c-dark-900: 245 246 248;
    --c-dark-800: 255 255 255;
    --c-dark-700: 234 236 239;
    --c-dark-600: 234 236 239;
    --c-dark-500: 205 209 214;
    --surface: #ffffff;
    --surface-2: #f5f5f5;
    --surface-hover: #f0f1f3;
    --border: #eaecef;
    --border-hover: #cdd1d6;
    --text: #181a20;
    --text-muted: #707a8a;
    --hover-overlay: rgba(0, 0, 0, 0.04);
}

/* ─── Tipografia de números (BinancePlex → IBM Plex Sans) ────── */
/* Valores monetários, percentuais e estatísticas usam a fonte
   tabular distinta do texto (Inter). As classes semânticas de
   valor já cobrem a maioria dos números automaticamente. */
.num,
.text-income,
.text-expense {
    font-family: 'IBM Plex Sans', 'Inter', system-ui, sans-serif;
    font-feature-settings: 'tnum' 1;
    font-variant-numeric: tabular-nums;
}

/* ─── Glass Effects (now flat) ───────────────────────────────── */
.glass-card {
    background: var(--surface);
    border: 1px solid var(--border);
}

.glass-card-solid {
    background: var(--surface);
    border: 1px solid var(--border);
}

/* ─── Cards ──────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
    border-color: var(--border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.card-glow {
    position: relative;
}

/* ─── Form Elements ──────────────────────────────────────────── */
.form-input {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: rgba(252, 213, 53, 0.5);
    box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.1);
}

.form-input::placeholder {
    color: rgba(107, 114, 128, 0.8);
}

.form-select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.form-select:focus {
    border-color: rgba(252, 213, 53, 0.5);
    box-shadow: 0 0 0 3px rgba(252, 213, 53, 0.1);
}

.form-select option {
    background: var(--surface);
    color: var(--text);
}

.form-input-color {
    width: 3rem;
    height: 2.5rem;
    padding: 0.25rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(156, 163, 175, 1);
    margin-bottom: 0.375rem;
}

.form-error {
    color: #f6465d;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    cursor: pointer;
    outline: none;
    border: none;
}

.btn-primary {
    background: #fcd535;
    color: #181a20;
    box-shadow: 0 4px 14px rgba(252, 213, 53, 0.25);
}

.btn-primary:hover {
    background: #f0b90b;
    box-shadow: 0 6px 20px rgba(252, 213, 53, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-success {
    background: #0ecb81;
    color: #fff;
    box-shadow: 0 4px 14px rgba(14, 203, 129, 0.25);
}

.btn-success:hover {
    background: #0bb974;
    box-shadow: 0 6px 20px rgba(14, 203, 129, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: #f6465d;
    color: #fff;
    box-shadow: 0 4px 14px rgba(246, 70, 93, 0.25);
}

.btn-danger:hover {
    background: #e03e54;
    box-shadow: 0 6px 20px rgba(246, 70, 93, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: rgba(156, 163, 175, 1);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    color: var(--text);
    background: var(--hover-overlay);
    border-color: var(--border-hover);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 0.375rem;
}

/* ─── Status Badges ──────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-paid {
    background: rgba(14, 203, 129, 0.15);
    color: #0ecb81;
    border: 1px solid rgba(14, 203, 129, 0.2);
}

.badge-pending {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.badge-income {
    background: rgba(14, 203, 129, 0.15);
    color: #0ecb81;
}

.badge-expense {
    background: rgba(246, 70, 93, 0.15);
    color: #f6465d;
}

/* ─── Tag Pills ──────────────────────────────────────────────── */
.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* ─── Progress Bar ───────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: var(--hover-overlay);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(252, 213, 53, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(252, 213, 53, 0);
    }
}

.animate-fade-in-up {
    animation: fadeInUp 0.4s ease-out;
}

.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}

.animate-pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* New row highlight (for HTMX inserts) */
.new-row {
    animation: fadeInUp 0.5s ease-out;
    background: rgba(252, 213, 53, 0.04) !important;
}

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(11, 14, 17, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(252, 213, 53, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(252, 213, 53, 0.5);
}

/* ─── Checkbox Overrides (for tags) ──────────────────────────── */
.tag-checkbox input[type="checkbox"] {
    display: none;
}

.tag-checkbox label {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--hover-overlay);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.tag-checkbox input[type="checkbox"]:checked + label {
    background: rgba(252, 213, 53, 0.15);
    border-color: rgba(252, 213, 53, 0.5);
    color: #fcd535;
}

.tag-checkbox label:hover {
    border-color: rgba(252, 213, 53, 0.3);
}

/* ─── Table ──────────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table th {
    padding: 0.75rem 1rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(156, 163, 175, 0.7);
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    border-bottom: 1px solid rgba(43, 49, 57, 0.6);
    transition: background 0.15s ease;
}

.data-table tr:hover td {
    background: var(--hover-overlay);
}

/* ─── Utilities ──────────────────────────────────────────────── */
.text-income {
    color: #0ecb81;
}

.text-expense {
    color: #f6465d;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 1.5rem 0;
}

/* Stat card — flat, sem gradiente inferior */
.stat-card {
    position: relative;
    padding: 1.5rem;
    border-radius: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: rgba(107, 114, 128, 0.8);
}

.empty-state svg {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 1rem;
    opacity: 0.3;
}

/* ─── Quick Date Picker ──────────────────────────────────────── */
.date-picker-wrap {
    position: relative;
}

.date-picker-wrap .form-input {
    padding-right: 2.5rem;
}

.date-picker-toggle {
    position: absolute;
    right: 0.625rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(156, 163, 175, 1);
    transition: color 0.2s ease;
}

.date-picker-toggle:hover {
    color: #fcd535;
}

.date-picker-panel {
    position: absolute;
    z-index: 40;
    top: calc(100% + 0.5rem);
    left: 0;
    width: 100%;
    min-width: 17rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 14px 35px rgba(0, 0, 0, 0.5);
    padding: 0.75rem;
}

.date-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.625rem;
}

.date-picker-header button {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 0.375rem;
    color: rgba(156, 163, 175, 1);
    transition: all 0.2s ease;
}

.date-picker-header button:hover {
    color: #fcd535;
    background: var(--hover-overlay);
}

.date-picker-header span {
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
}

.date-picker-weekdays,
.date-picker-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.25rem;
}

.date-picker-weekdays span {
    color: rgba(107, 114, 128, 1);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.04em;
    padding: 0.2rem 0;
}

.date-picker-day {
    height: 2rem;
    border-radius: 0.375rem;
    color: var(--text);
    font-size: 0.8rem;
    transition: all 0.15s ease;
}

.date-picker-day:hover {
    background: rgba(252, 213, 53, 0.15);
    color: #fcd535;
}

.date-picker-day.is-today {
    box-shadow: inset 0 0 0 1px rgba(252, 213, 53, 0.7);
}

.date-picker-day.is-selected {
    background: #fcd535;
    color: #181a20;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(252, 213, 53, 0.3);
}

.date-picker-day.is-outside {
    color: rgba(107, 114, 128, 0.7);
    opacity: 0.5;
    cursor: default;
}

@media (max-width: 640px) {
    .date-picker-panel {
        min-width: 15.5rem;
    }
}

/* Keep quick-entry date picker visible outside glow card bounds */
.quick-entry-card {
    overflow: visible;
}

/* Mobile transaction/card expandable action rows */
@media (max-width: 639px) {
    .txn-card .txn-actions,
    .cc-card .cc-actions,
    .rec-card .rec-actions {
        display: none;
    }
    .txn-card.mobile-expanded .txn-actions,
    .cc-card.mobile-expanded .cc-actions,
    .rec-card.mobile-expanded .rec-actions {
        display: flex;
    }
    .txn-card.mobile-expanded {
        background: var(--surface-hover);
        border-radius: 0.75rem;
    }
    .cc-card.mobile-expanded {
        border-color: var(--border-hover);
    }
    .rec-card.mobile-expanded {
        background: var(--surface-hover);
        border-radius: 0.75rem;
    }
}

/* Dynamic display of empty states when container has items */
#cards-list:has(> :not(.empty-state)) > .empty-state {
    display: none !important;
}

/* Seleção de Abas de Metas */
#goals-grid.tab-active-selected .is-archived-goal { display: none !important; }
#goals-grid.tab-archived-selected .is-active-goal { display: none !important; }

/* Exibição condicional do empty state de metas com :has */
#goals-grid.tab-active-selected:has(.goal-card.is-active-goal) .empty-state-active { display: none !important; }
#goals-grid.tab-archived-selected:has(.goal-card.is-archived-goal) .empty-state-archived { display: none !important; }

/* Seleção de Abas de Regras Recorrentes */
#recurring-list.tab-active-selected .is-archived-rule { display: none !important; }
#recurring-list.tab-archived-selected .is-active-rule { display: none !important; }

/* Exibição condicional do empty state de regras recorrentes com :has */
#recurring-list.tab-active-selected:has(.recurring-row.is-active-rule) .empty-state-active { display: none !important; }
#recurring-list.tab-archived-selected:has(.recurring-row.is-archived-rule) .empty-state-archived { display: none !important; }

/* ═══════════════════════════════════════════════════════════════
   Tema Claro — overrides dos utilitários Tailwind inline
   (escopo html.light garante maior especificidade que as classes)
   ═══════════════════════════════════════════════════════════════ */

/* Texto */
html.light .text-white { color: #181a20; }
html.light .text-gray-100,
html.light .text-gray-200,
html.light .text-gray-300 { color: #1e2329; }
html.light .text-gray-400 { color: #707a8a; }
html.light .text-gray-500 { color: #929aa5; }
html.light .text-gray-600 { color: #aeb4bc; }

/* Mantém texto branco em botões de fundo sólido colorido */
html.light .bg-red-500.text-white,
html.light .bg-red-600.text-white { color: #ffffff; }

/* Sobreposições brancas → sutis escuras */
html.light .bg-white\/5,
html.light .bg-white\/8,
html.light .bg-white\/10,
html.light .bg-white\/12,
html.light .bg-white\/\[0\.02\],
html.light .bg-white\/\[0\.025\] { background-color: rgba(0, 0, 0, 0.04); }

html.light .hover\:bg-white\/5:hover,
html.light .hover\:bg-white\/10:hover,
html.light .hover\:bg-white\/12:hover,
html.light .hover\:bg-white\/\[0\.02\]:hover { background-color: rgba(0, 0, 0, 0.06); }

/* Bordas brancas → hairlines claras */
html.light .border-white\/5,
html.light .border-white\/10,
html.light .border-white\/15,
html.light .border-white\/20,
html.light .border-white\/\[0\.08\] { border-color: #eaecef; }

html.light .hover\:border-white\/10:hover,
html.light .hover\:border-white\/15:hover,
html.light .hover\:border-white\/20:hover { border-color: #cdd1d6; }

/* Tooltip do gráfico (Chart.js usa cor inline, sem ajuste necessário) */

/* ─── Botão de alternância de tema ───────────────────────────── */
.theme-to-dark { display: none; }
.theme-to-light { display: inline-flex; }
html.light .theme-to-light { display: none; }
html.light .theme-to-dark { display: inline-flex; }
