
:root {
    --bg-dark: #0D1117;
    --bg-dark-soft: #161B22;
    --bg-input: #21262D;
    --text-primary: #E6EDF3;
    --text-muted: #8B949E;
    --accent: #22C55E;
    --accent-secondary: #0EA5E9;
    --info: #0EA5E9;
    --danger: #F85149;
    --success: #22C55E;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Outfit', 'Segoe UI', system-ui, sans-serif;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
}

.bg-dark-soft { background-color: var(--bg-dark-soft); }
.bg-dark-input { background-color: var(--bg-input); }
.text-accent { color: var(--accent); }
.text-info-bright { color: var(--info); }
.text-danger-bright { color: var(--danger); }
.extra-small { font-size: 0.7rem; }

/* Dashboard Cards */
.card {
    border-radius: 24px;
    background-color: var(--bg-dark-soft);
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.display-4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: normal;
}

/* Botón Flotante (FAB) */
.btn-fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--accent);
    color: #000;
    border: none;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: transform 0.2s;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.btn-fab:active { transform: scale(0.9); }

/* List Item */
.list-group-item {
    background-color: var(--bg-dark-soft);
    border-color: rgba(255, 255, 255, 0.06);
    padding: 16px 20px;
}
.list-group-item:last-child { border-bottom: 0; }

/* Modal tweaks */
.modal-content {
    border-radius: 28px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.btn-accent {
    background-color: var(--accent);
    color: #000;
    font-weight: 600;
    border-radius: 14px;
    padding: 10px 20px;
}

/* Form styling */
.form-control, .form-select {
    border-radius: 14px;
}

.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 2px var(--accent);
    background-color: var(--bg-input);
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background-color: var(--bg-dark-soft);
    border: 1px solid var(--accent);
    border-radius: 20px;
    padding: 15px 20px;
    margin-bottom: 10px;
    min-width: 280px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    animation: slideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid #ffa726; }

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

.toast.removing { animation: slideOut 0.3s ease-in; }

/* Status Badges */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-ok { background-color: rgba(102, 187, 106, 0.2); color: var(--success); }
.badge-warning { background-color: rgba(255, 167, 38, 0.2); color: #ffa726; }
.badge-critical { background-color: rgba(239, 83, 80, 0.2); color: var(--danger); }

/* Budget Alert Banner */
.alert-banner {
    background: linear-gradient(135deg, rgba(248, 81, 73, 0.15), rgba(248, 81, 73, 0.05));
    border-left: 4px solid var(--danger);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Progress Bar Animations */
.progress-bar {
    transition: width 0.6s ease-out, background-color 0.3s ease;
}

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn-loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* List Item Animation */
.list-group-item {
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Optimizations */
@media (hover: none) {
    .btn-fab:active {
        transform: scale(0.92);
        background-color: #16a34a;
    }

    .btn:active {
        transform: scale(0.98);
    }
}

/* Enhanced Touch Targets */
.form-control, .form-select, .btn {
    min-height: 44px;
}

/* Number Input Optimization */
input[type="number"] {
    font-family: 'Outfit', sans-serif;
    font-size: 1.2rem;
    font-weight: 600;
    text-align: center;
}

/* Monetary values */
.display-4, .h3, .h4 {
    font-family: 'Outfit', sans-serif;
}

/* Negative Value Warning */
.text-negative {
    color: var(--danger);
    font-weight: 700;
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Cycle Navigation */
.btn-outline-accent {
    border-color: var(--accent);
    color: var(--accent);
    border-radius: 14px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.btn-outline-accent:hover:not(:disabled) {
    background-color: var(--accent);
    color: #000;
}

.btn-outline-accent:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

#cicloActual {
    font-size: 0.95rem;
    text-transform: capitalize;
}

/* Delete Button */
.btn-outline-danger {
    border-color: var(--danger);
    color: var(--danger);
    padding: 4px 8px;
    border-radius: 14px;
}

.btn-outline-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-outline-danger:active {
    transform: scale(0.95);
}

/* Info Period Card */
.bg-gradient-accent {
    background-color: var(--bg-dark-soft);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-left: 4px solid var(--accent);
}

.info-box {
    padding: 8px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.15);
}

.text-white-50 {
    color: var(--text-muted);
}

/* Collapse icon animation */
#iconCollapse {
    transition: transform 0.25s ease-out;
    display: inline-block;
}

.collapsed #iconCollapse {
    transform: rotate(-90deg);
}

/* Badge compras */
.badge.bg-accent {
    background-color: var(--accent) !important;
}

/* Custom Progress Bar */
.progress-bar-custom {
    width: 100%;
    height: 32px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.8s ease, background 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 40px;
}

.progress-bar-text {
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    position: absolute;
    width: 100%;
    text-align: center;
}

/* Gradient colors based on percentage */
.progress-bar-fill.level-low {
    background: linear-gradient(90deg, #22c55e, #16a34a);
}

.progress-bar-fill.level-medium {
    background: linear-gradient(90deg, #eab308, #ca8a04);
}

.progress-bar-fill.level-high {
    background: linear-gradient(90deg, #f97316, #ea580c);
}

.progress-bar-fill.level-critical {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    animation: pulse-danger 1.5s ease-in-out infinite;
}

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* Login Screen */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: linear-gradient(135deg, #0D1117 0%, #161B22 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.login-container {
    width: 90%;
    max-width: 400px;
    padding: 48px 32px;
    background-color: var(--bg-dark-soft);
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.login-icon {
    font-size: 4rem;
    color: var(--accent);
}

.pin-input {
    font-size: 2rem !important;
    letter-spacing: 0.5rem;
    font-weight: 700;
    padding: 20px !important;
    border-radius: 14px !important;
}

.pin-input:focus {
    box-shadow: 0 0 0 3px var(--accent) !important;
}

/* Login animations */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-10px); }
    20%, 40%, 60%, 80% { transform: translateX(10px); }
}

.shake {
    animation: shake 0.6s;
}

/* === Loading Skeleton === */
.skeleton-pulse {
    background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 50%, rgba(255,255,255,0.05) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.skeleton-line {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-line-lg {
    height: 2rem;
    margin-bottom: 0.75rem;
    width: 60%;
}

.skeleton-line-sm {
    height: 0.75rem;
    width: 40%;
}

/* === Offline Banner === */
.offline-banner {
    position: sticky;
    top: 56px;
    z-index: 1030;
    background: #d97706;
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* === FAB disabled state === */
.btn-fab[disabled] {
    opacity: 0.5;
    pointer-events: none;
}

/* === Focus indicators (a11y) === */
.btn:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible {
    outline: 2px solid var(--accent, #22C55E);
    outline-offset: 2px;
    box-shadow: none;
}

.btn-fab:focus-visible {
    outline: 3px solid var(--accent, #22C55E);
    outline-offset: 3px;
}

/* === Delete modal === */
#deleteModal .modal-content {
    border: 1px solid rgba(220, 53, 69, 0.3);
}

/* === Reduced motion (all decorative animations) === */
@media (prefers-reduced-motion: reduce) {
    .skeleton-pulse,
    .list-group-item,
    .toast,
    .toast.removing,
    .text-negative,
    .alert-banner,
    .progress-bar-fill.level-critical {
        animation: none;
    }
    .modal.fade .modal-dialog,
    .progress-bar,
    .progress-bar-fill,
    body,
    #iconCollapse {
        transition: none;
    }
}

/* === Light Theme === */
[data-theme="light"] {
    --bg-dark: #F6F8FA;
    --bg-dark-soft: #FFFFFF;
    --bg-input: #F0F2F5;
    --text-primary: #1F2328;
    --text-muted: #656D76;
    --accent: #15803D;
    --accent-secondary: #0369A1;
    --info: #0369A1;
    --danger: #CF222E;
    --success: #15803D;
}

[data-theme="light"] body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
}

[data-theme="light"] .navbar {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .card {
    background-color: var(--bg-dark-soft) !important;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .modal-content {
    background-color: var(--bg-dark-soft) !important;
    color: var(--text-primary);
}

[data-theme="light"] .form-control,
[data-theme="light"] .form-select {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: #cbd5e1;
}

[data-theme="light"] .text-white {
    color: var(--text-primary) !important;
}

[data-theme="light"] .btn-outline-light {
    color: var(--text-primary);
    border-color: #cbd5e1;
}

[data-theme="light"] .btn-outline-light:hover {
    background-color: #f1f5f9;
    color: var(--text-primary);
}

[data-theme="light"] .list-group-item {
    background-color: var(--bg-dark-soft);
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .login-screen {
    background: linear-gradient(135deg, #F6F8FA 0%, #EAEEF2 100%);
}

[data-theme="light"] .login-container {
    background-color: #FFFFFF;
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .offline-banner {
    background: #f59e0b;
}

[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

[data-theme="light"] .bg-gradient-accent {
    background-color: var(--bg-dark-soft);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-left: 4px solid var(--accent);
}

[data-theme="light"] .info-box {
    background: rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .text-white-50 {
    color: var(--text-muted);
}

[data-theme="light"] .toast {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* === Navbar — One UI style === */
.navbar {
    background-color: var(--bg-dark-soft);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: none;
    color: var(--text-primary);
}

.navbar .navbar-brand {
    color: var(--text-primary) !important;
}

/* === Body transition === */
body {
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* === FAB overlap fix === */
#collapseCompras {
    padding-bottom: 80px;
}

/* === Mobile toast positioning === */
@media (max-width: 576px) {
    .toast-container {
        top: auto !important;
        bottom: 100px;
        right: 16px;
        left: 16px;
    }
    .toast {
        min-width: auto;
        width: 100%;
    }
    .navbar .btn-sm {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

