/* ═══════════════════════════════════════════════════════════════
   COKI STUDIOS GLOBAL TOOLBAR & NAVBAR STYLES
   Soporte perfecto para Modo Claro y Modo Oscuro (Apple / Google)
   ═══════════════════════════════════════════════════════════════ */

nav,
.felte-nav,
.cs-header,
.cs-nav {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(6, 9, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* ── MODO CLARO UNIVERSAL PARA TOOLBAR / NAVBAR ── */
html.light-theme nav,
html.light-theme .felte-nav,
html.light-theme .cs-header,
html.light-theme .cs-nav {
    background: rgba(255, 255, 255, 0.88) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.03) !important;
}

/* ── MARCA Y LOGO ── */
.nav-brand-name,
.nav-brand-title,
.cs-logo-title span {
    color: #f1f5f9;
    transition: color 0.2s ease;
}

html.light-theme .nav-brand-name,
html.light-theme .nav-brand-title,
html.light-theme .cs-logo-title span {
    color: #0f172a !important;
}

/* ── ENLACES DE NAVEGACIÓN ── */
.nav-link,
.btn-nav-ghost,
.cs-nav-link {
    color: #94a3b8;
    transition: color 0.2s ease, background 0.2s ease;
}

.nav-link:hover,
.nav-link.active,
.btn-nav-ghost:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.07);
}

html.light-theme .nav-link,
html.light-theme .btn-nav-ghost,
html.light-theme .cs-nav-link {
    color: #475569 !important;
}

html.light-theme .nav-link:hover,
html.light-theme .nav-link.active,
html.light-theme .btn-nav-ghost:hover {
    color: #0f172a !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

/* ── SELECTOR DE IDIOMA ── */
.lang-select,
#lang-switcher {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
    transition: all 0.2s ease;
}

html.light-theme .lang-select,
html.light-theme #lang-switcher {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: #0f172a !important;
}

/* ── BOTÓN DE CAMBIO DE TEMA ── */
.theme-toggle-btn,
#theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s ease;
}

.theme-toggle-btn:hover,
#theme-toggle:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

html.light-theme .theme-toggle-btn,
html.light-theme #theme-toggle {
    color: #475569 !important;
}

html.light-theme .theme-toggle-btn:hover,
html.light-theme #theme-toggle:hover {
    color: #0f172a !important;
    background: rgba(0, 0, 0, 0.05) !important;
}

/* ── BARRA DE BÚSQUEDA EN NAVBAR ── */
.search-container {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

html.light-theme .search-container {
    background: rgba(0, 0, 0, 0.04) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

html.light-theme .search-input {
    color: #0f172a !important;
}

html.light-theme .search-input::placeholder {
    color: #94a3b8 !important;
}

/* ═══════════════════════════════════════════════════════════════
   CS WAFLERA (UNIVERSAL APP LAUNCHER) & COHERENCIA VISUAL
   ═══════════════════════════════════════════════════════════════ */

.cs-waffle-btn,
#cs-waffle-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    color: #94a3b8;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    flex-shrink: 0;
    padding: 0;
}

.cs-waffle-btn:hover,
#cs-waffle-toggle:hover,
.cs-waffle-btn.active,
#cs-waffle-toggle.active {
    color: #ffffff;
    background: rgba(99, 102, 241, 0.14);
    border-color: rgba(99, 102, 241, 0.35);
}

html.light-theme .cs-waffle-btn,
html.light-theme #cs-waffle-toggle {
    color: #475569 !important;
}

html.light-theme .cs-waffle-btn:hover,
html.light-theme #cs-waffle-toggle:hover,
html.light-theme .cs-waffle-btn.active,
html.light-theme #cs-waffle-toggle.active {
    color: #4f46e5 !important;
    background: rgba(79, 70, 229, 0.1) !important;
    border-color: rgba(79, 70, 229, 0.28) !important;
}

.cs-waffle-btn svg {
    width: 18px;
    height: 18px;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cs-waffle-btn:hover svg,
.cs-waffle-btn.active svg {
    transform: scale(1.08);
}

/* Floating Waflera Wrapper when auto-injected on standalone pages */
.cs-waffle-floating-bar {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px;
    border-radius: 14px;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

html.light-theme .cs-waffle-floating-bar {
    background: rgba(255, 255, 255, 0.92) !important;
    border-color: rgba(15, 23, 42, 0.1) !important;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.1) !important;
}

/* Popover Container */
.cs-waffle-popover {
    position: fixed;
    top: 64px;
    right: 20px;
    width: 348px;
    max-width: calc(100vw - 24px);
    z-index: 10000;
    background: rgba(11, 15, 25, 0.96);
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 22px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.68), 0 0 0 1px rgba(99, 102, 241, 0.16);
    padding: 18px 16px 14px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.97);
    transform-origin: top right;
    transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.2s;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    user-select: none;
}

.cs-waffle-popover.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

html.light-theme .cs-waffle-popover {
    background: rgba(255, 255, 255, 0.97) !important;
    border-color: rgba(15, 23, 42, 0.1) !important;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16), 0 4px 16px rgba(15, 23, 42, 0.06) !important;
}

.cs-waffle-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 12px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

html.light-theme .cs-waffle-header {
    border-bottom-color: rgba(15, 23, 42, 0.07) !important;
}

.cs-waffle-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: #f8fafc;
}

html.light-theme .cs-waffle-title {
    color: #0f172a !important;
}

.cs-waffle-title img {
    width: 20px;
    height: 20px;
    border-radius: 5px;
}

.cs-waffle-badge {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

html.light-theme .cs-waffle-badge {
    background: rgba(79, 70, 229, 0.1) !important;
    color: #4f46e5 !important;
    border-color: rgba(79, 70, 229, 0.25) !important;
}

.cs-waffle-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    max-height: calc(100vh - 170px);
    overflow-y: auto;
    scrollbar-width: none;
}

.cs-waffle-grid::-webkit-scrollbar {
    display: none;
}

.cs-waffle-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px 6px 8px;
    border-radius: 14px;
    text-decoration: none;
    color: #f1f5f9;
    border: 1px solid transparent;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
}

.cs-waffle-item:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.09);
    transform: translateY(-2px);
}

.cs-waffle-item.current {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.35);
}

html.light-theme .cs-waffle-item {
    color: #0f172a !important;
}

html.light-theme .cs-waffle-item:hover {
    background: #f1f5f9 !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

html.light-theme .cs-waffle-item.current {
    background: rgba(79, 70, 229, 0.08) !important;
    border-color: rgba(79, 70, 229, 0.28) !important;
}

.cs-waffle-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 7px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html.light-theme .cs-waffle-icon-wrap {
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}

.cs-waffle-item:hover .cs-waffle-icon-wrap {
    transform: scale(1.07);
}

.cs-waffle-icon-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cs-waffle-label {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    color: inherit;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 92px;
}

.cs-waffle-sub {
    font-size: 10px;
    font-weight: 500;
    color: #64748b;
    margin-top: 2px;
    white-space: nowrap;
}

html.light-theme .cs-waffle-sub {
    color: #64748b !important;
}

.cs-waffle-footer {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

html.light-theme .cs-waffle-footer {
    border-top-color: rgba(15, 23, 42, 0.07) !important;
}

.cs-waffle-footer-link {
    font-size: 11.5px;
    font-weight: 600;
    color: #94a3b8;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 9px;
    transition: all 0.18s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cs-waffle-footer-link:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.06);
}

.cs-waffle-footer-link.primary {
    color: #818cf8;
    background: rgba(99, 102, 241, 0.1);
}

.cs-waffle-footer-link.primary:hover {
    color: #ffffff;
    background: #6366f1;
}

html.light-theme .cs-waffle-footer-link {
    color: #475569 !important;
}

html.light-theme .cs-waffle-footer-link:hover {
    color: #0f172a !important;
    background: #f1f5f9 !important;
}

html.light-theme .cs-waffle-footer-link.primary {
    color: #4f46e5 !important;
    background: rgba(79, 70, 229, 0.08) !important;
}

html.light-theme .cs-waffle-footer-link.primary:hover {
    color: #ffffff !important;
    background: #4f46e5 !important;
}

/* ═══════════════════════════════════════════════════════════════
   UNIVERSAL THEME VARIABLES & COHERENCE (LIGHT & DARK MODE)
   Garantiza contraste accesible y paleta oficial en todo CS
   ═══════════════════════════════════════════════════════════════ */

:root, html.dark-theme {
    --bg: #06090f;
    --bg2: #0d1117;
    --card: rgba(255, 255, 255, 0.04);
    --card-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.4);
    --accent: #6366f1;
    --accent2: #8b5cf6;
    --green: #10b981;
    --text: #f1f5f9;
    --text-sub: #94a3b8;
    --text-muted: #64748b;
    --cs-bg: #06090f;
    --cs-bg-card: #0d1117;
    --cs-bg-card-sub: #161b22;
    --cs-bg-input: #0a0d14;
    --cs-text-bright: #f1f5f9;
    --cs-text-sub: #94a3b8;
    --cs-text-muted: #64748b;
}

html.light-theme {
    --bg: #f8fafc;
    --bg2: #f1f5f9;
    --card: #ffffff;
    --card-hover: #f8fafc;
    --border: rgba(15, 23, 42, 0.09);
    --border-glow: rgba(79, 70, 229, 0.25);
    --accent: #4f46e5;
    --accent2: #7c3aed;
    --green: #059669;
    --text: #0f172a;
    --text-sub: #475569;
    --text-muted: #64748b;
    --cs-bg: #f8fafc;
    --cs-bg-card: #ffffff;
    --cs-bg-card-sub: #f1f5f9;
    --cs-bg-input: #ffffff;
    --cs-text-bright: #0f172a;
    --cs-text-sub: #475569;
    --cs-text-muted: #64748b;
}

/* Base Body Color Transition */
body {
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.25s ease, color 0.2s ease;
}

html.light-theme body {
    background-color: #f8fafc;
    color: #0f172a;
}

/* Light Theme Overrides for Core UI Components */
html.light-theme .cs-panel {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.04) !important;
}

html.light-theme .dev-top-banner {
    background: linear-gradient(135deg, #ffffff, #eff6ff) !important;
    border-color: rgba(99, 102, 241, 0.25) !important;
}

html.light-theme .dev-banner-title {
    background: linear-gradient(135deg, #0f172a 30%, #0284c7 100%) !important;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
}

html.light-theme .dev-metric-box {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
}

html.light-theme .cs-tabs-bar {
    background: rgba(15, 23, 42, 0.04) !important;
    border-color: rgba(15, 23, 42, 0.09) !important;
}

html.light-theme .cs-tab-btn {
    color: #64748b !important;
}

html.light-theme .cs-tab-btn:hover {
    color: #0f172a !important;
    background: rgba(15, 23, 42, 0.05) !important;
}

html.light-theme .cs-tab-btn.active {
    color: #4f46e5 !important;
    background: #ffffff !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06) !important;
}

html.light-theme .cs-code-box {
    background: #0b1120 !important;
    color: #f8fafc !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
}

html.light-theme .cs-input,
html.light-theme input[type="text"],
html.light-theme input[type="password"],
html.light-theme input[type="email"],
html.light-theme textarea,
html.light-theme select {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
    color: #0f172a !important;
}

html.light-theme .pkg-card {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.09) !important;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.03) !important;
}

html.light-theme .btn-hero-secondary {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.15) !important;
    color: #0f172a !important;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04) !important;
}

html.light-theme .btn-hero-secondary:hover {
    background: #f8fafc !important;
    border-color: rgba(79, 70, 229, 0.35) !important;
    color: #4f46e5 !important;
}
