/* ==========================================
   BRACHLINE - THEME SYSTEM
   Sistema de temas claro/oscuro con Tailwind
   ========================================== */

/* Variables de tema claro */
[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-hero: #000000;
    --text-primary: #000000;
    --text-secondary: #666666;
    --text-hero: #ffffff;
    --border-color: #e5e7eb;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --btn-primary-bg: #000000;
    --btn-primary-text: #ffffff;
    --btn-primary-border: #ffffff;
    --navbar-bg: rgba(255, 255, 255, 0.95);
    --navbar-text: #000000;
    --navbar-text-transparent: #ffffff;
    --card-bg: #ffffff;
    --footer-bg: #000000;
    --footer-text: #ffffff;
    --logo-filter-scrolled: none;
}

/* Variables de tema oscuro */
[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #1a1a1a;
    --bg-hero: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --text-hero: #ffffff;
    --border-color: #2a2a2a;
    --shadow-color: rgba(255, 255, 255, 0.05);
    --btn-primary-bg: #ffffff;
    --btn-primary-text: #000000;
    --btn-primary-border: #000000;
    --navbar-bg: rgba(10, 10, 10, 0.95);
    --navbar-text: #ffffff;
    --navbar-text-transparent: #ffffff;
    --card-bg: #111111;
    --footer-bg: #000000;
    --footer-text: #ffffff;
    --logo-filter-scrolled: brightness(0) invert(1);

    /* Buttons */
    .btn-primary {
        background: var(--btn-primary-bg) !important;
        color: var(--btn-primary-text) !important;
        border-color: var(--btn-primary-border) !important;
    }

    .btn-primary:hover {
        background: var(--btn-primary-text) !important;
        color: var(--btn-primary-bg) !important;
    }

    .btn-secondary {
        background: var(--bg-primary);
        color: var(--text-primary);
        border-color: var(--text-primary);
    }

    .btn-secondary:hover {
        background: var(--text-primary);
        color: var(--bg-primary);
    }

    /* Cards */
    .card {
        background: var(--card-bg) !important;
        border-color: var(--border-color) !important;
        color: var(--text-primary);
    }

    .card h3 {
        color: var(--text-primary) !important;
    }

    .card p {
        color: var(--text-secondary) !important;
    }

    .card::before {
        background: var(--text-primary) !important;
    }

    .card:hover {
        border-color: var(--text-primary) !important;
    }

    /* Sections */
    section {
        background: var(--bg-primary);
    }

    section[style*="background: #f9fafb"] {
        background: var(--bg-secondary) !important;
    }

    .section-header h2 {
        color: var(--text-primary) !important;
    }

    .section-header p {
        color: var(--text-secondary) !important;
    }

    /* Footer */
    footer {
        background: var(--footer-bg) !important;
        color: var(--footer-text) !important;
    }

    footer h3,
    footer h4,
    footer a {
        color: var(--footer-text) !important;
    }

    /* Mega Menu */
    .mega-menu {
        background: var(--card-bg) !important;
        border-color: var(--border-color) !important;
    }

    .mega-item {
        color: var(--text-primary);
    }

    .mega-item:hover {
        background: var(--bg-secondary) !important;
    }

    .mega-icon {
        background: var(--text-primary) !important;
        color: var(--bg-primary) !important;
    }

    /* Fluid Background */
    .fluid-bg {
        background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%) !important;
    }

    [data-theme="dark"] .fluid-bg::before,
    [data-theme="dark"] .fluid-bg::after {
        background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 50%, transparent 100%) !important;
    }

    /* Mobile Menu */
    .menu-toggle span {
        background: var(--navbar-text-transparent);
    }

    .navbar.scrolled .menu-toggle span,
    .navbar.menu-open .menu-toggle span {
        background: var(--navbar-text) !important;
    }

    @media (max-width: 768px) {
        .nav-links {
            background: var(--card-bg) !important;
        }

        .nav-item {
            color: var(--text-primary) !important;
        }

        .nav-item::after {
            background: var(--text-primary) !important;
        }
    }

    /* Sidebar (Dashboard) */
    .sidebar {
        background: var(--card-bg) !important;
        border-color: var(--border-color) !important;
    }

    .sidebar-item {
        color: var(--text-primary);
    }

    .sidebar-item:hover {
        background: var(--bg-secondary) !important;
    }

    .sidebar-item.active {
        background: var(--text-primary) !important;
        color: var(--bg-primary) !important;
    }

    /* Inputs & Forms */
    input,
    textarea,
    select {
        background: var(--card-bg) !important;
        color: var(--text-primary) !important;
        border-color: var(--border-color) !important;
    }

    input:focus,
    textarea:focus,
    select:focus {
        border-color: var(--text-primary) !important;
    }

    /* Smooth transitions for all theme changes */
    * {
        transition: background-color 0.3s ease,
            color 0.3s ease,
            border-color 0.3s ease,
            box-shadow 0.3s ease;
    }
}

/* ==========================================
   THEME SWITCH IMPROVEMENTS
   ========================================== */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 64px;
    height: 32px;
    margin-right: 1.5rem;
    vertical-align: middle;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #f3f4f6;
    transition: .4s;
    border-radius: 34px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    border: 1px solid #d1d5db;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.theme-slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s cubic-bezier(0.4, 0.0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

input:checked+.theme-slider {
    background-color: #1f2937;
    border-color: #374151;
}

input:checked+.theme-slider:before {
    transform: translateX(32px);
    background-color: #374151;
    border: 1px solid #4b5563;
}

.sun-icon {
    color: #f59e0b;
    width: 16px;
    height: 16px;
    z-index: 1;
    transition: all 0.3s ease;
}

.moon-icon {
    color: #9ca3af;
    width: 16px;
    height: 16px;
    z-index: 1;
    transition: all 0.3s ease;
}

input:checked+.theme-slider .sun-icon {
    opacity: 1;
    color: #ffffff;
}

input:checked+.theme-slider .moon-icon {
    opacity: 1;
    color: #fbbf24;
}

/* Hover effects */
.theme-switch:hover .theme-slider:before {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    transform: scale(1.05);
}

input:checked+.theme-switch:hover .theme-slider:before {
    transform: translateX(32px) scale(1.05);
}