/* ============ v6: DarkLogic CRM branding + i18n switches + help + logo upload ============ */

/* Brand logo in sidebar - v3.5 mejorado (logo grande + sin recortes) */
.brand.brand-dl {
    padding: 22px 14px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: linear-gradient(180deg, rgba(123,97,255,.10) 0%, transparent 100%);
    border-bottom: 1px solid var(--brd);
    margin-bottom: 8px;
    position: relative;
    overflow: visible;
    transition: all .2s ease;
    min-height: 130px;
}
.brand.brand-dl::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(167,139,250,.14) 0%, transparent 60%);
    z-index: 0;
    animation: brandGlow 6s ease-in-out infinite;
    pointer-events: none;
    border-radius: inherit;
}
@keyframes brandGlow {
    0%,100% { opacity: .5; }
    50% { opacity: 1; }
}
.brand.brand-dl:hover { background: linear-gradient(180deg, rgba(123,97,255,.16) 0%, rgba(34,211,238,.05) 100%); }
.brand-logo-img {
    max-width: 90%;
    max-height: 96px;
    height: auto;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 14px rgba(167,139,250,.5)) drop-shadow(0 0 20px rgba(123,97,255,.3));
    position: relative;
    z-index: 2;
    transition: transform .2s ease;
    display: block;
}
.brand.brand-dl:hover .brand-logo-img { transform: scale(1.04); }
.brand.brand-dl::after {
    content: "DarkLogic CRM";
    display: block;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: 2.5px;
    color: var(--vlt);
    margin-top: 10px;
    text-transform: uppercase;
    background: linear-gradient(90deg, #A78BFA, #22D3EE);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    z-index: 2;
    opacity: .95;
    text-align: center;
}
[data-theme="light"] .brand.brand-dl {
    background: linear-gradient(180deg, rgba(123,97,255,.06) 0%, transparent 100%);
}
[data-theme="light"] .brand-logo-img {
    filter: drop-shadow(0 4px 14px rgba(167,139,250,.35));
}

/* Language switcher (topbar) */
.lang-switch {
    display: inline-flex;
    gap: 0;
    background: rgba(11,14,22,.5);
    border: 1px solid var(--brd);
    border-radius: 6px;
    overflow: hidden;
}
[data-theme="light"] .lang-switch { background: #F3F4F6 }
.lang-switch a {
    padding: 4px 10px;
    text-decoration: none;
    color: var(--mut);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: 1px;
    transition: all .15s;
}
.lang-switch a:hover { color: var(--tx); background: rgba(123,97,255,.15) }
.lang-switch a.active { background: var(--grad); color: #fff }

/* Theme switcher (dots) */
.theme-switch {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: rgba(11,14,22,.5);
    border: 1px solid var(--brd);
    border-radius: 6px;
}
[data-theme="light"] .theme-switch { background: #F3F4F6 }
.theme-switch a {
    width: 18px; height: 18px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all .15s;
}
.theme-switch a:hover { transform: scale(1.15); border-color: var(--vlt) }
.theme-switch a.active { border-color: var(--tx); box-shadow: 0 0 0 2px var(--vlt); transform: scale(1.1) }

/* ============ Help / tutorial page ============ */

.help-hero {
    text-align: center;
    padding: 30px 20px 20px;
    background: var(--hero-image), var(--surf);
    border-radius: 16px;
    border: 1px solid var(--brd);
    margin-bottom: 20px;
}
[data-theme="light"] .help-hero img { filter: none }
.help-hero h1 { font-size: 1.6rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
}
.help-card {
    position: relative;
    background: var(--surf);
    border: 1px solid var(--brd);
    border-radius: 12px;
    padding: 22px 20px 18px;
    transition: all .2s;
}
.help-card:hover { border-color: var(--vlt); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(123,97,255,.15) }
.help-num {
    position: absolute;
    top: 10px; right: 14px;
    font-size: 2rem;
    font-weight: 800;
    color: var(--vlt);
    opacity: .18;
    line-height: 1;
}
.help-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    margin-bottom: 12px;
}
.help-card p { color: var(--mut); font-size: .92rem }
.help-card p .mono { font-family: 'JetBrains Mono', monospace; background: rgba(123,97,255,.12); padding: 1px 6px; border-radius: 4px; font-size: .85em }
.help-card p b { color: var(--tx) }

/* ============ Logo upload UI (billing_settings) ============ */

.logo-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px }
.logo-slot {
    background: var(--surf2);
    border: 2px dashed var(--brd);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}
.logo-slot.dark  { background: #FFFFFF }
.logo-slot.white { background: #060713 }
.logo-slot .preview {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}
.logo-slot .preview img { max-height: 70px; max-width: 100%; object-fit: contain }
.logo-slot .preview .placeholder { color: rgba(148,163,184,.5); font-size: 2rem }
.logo-slot .preview.dark .placeholder  { color: #94A3B8 }
.logo-slot .preview.white .placeholder { color: #94A3B8 }
.logo-slot .lbl {
    font-size: .7rem;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 6px;
}
.logo-slot.dark  .lbl { color: #6B7280 }
.logo-slot.white .lbl { color: #94A3B8 }
.logo-slot input[type=file] {
    width: 100%;
    padding: 8px;
    background: transparent;
    color: var(--tx);
    border: 1px solid var(--brd);
    border-radius: 6px;
    font-size: .8rem;
    box-sizing: border-box;
}
.logo-slot.dark  input[type=file] { color: #1F2937; border-color: #D1D5DB; background: #F9FAFB }
.logo-slot.white input[type=file] { color: #EAE6FF; border-color: #1F2545; background: rgba(11,14,22,.6) }

/* Theme picker cards in profile */
.theme-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-top: 10px }
.theme-picker label {
    display: block;
    cursor: pointer;
    background: var(--surf2);
    border: 2px solid var(--brd);
    border-radius: 10px;
    padding: 12px;
    transition: all .2s;
    text-align: center;
}
.theme-picker input[type=radio] { display: none }
.theme-picker input[type=radio]:checked + .th-inner { border-color: var(--vlt) }
.theme-picker label:hover { border-color: var(--vlt) }
.theme-picker .th-swatch {
    height: 60px;
    border-radius: 8px;
    margin-bottom: 8px;
}
.theme-picker .th-name { font-weight: 700; font-size: .9rem }

/* Kbd */
.kbd { background: var(--surf2); border: 1px solid var(--brd); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: .8em }

/* Mobile */
@media (max-width: 900px) {
    .who .lang-switch, .who .theme-switch { display: none }
    .help-grid { grid-template-columns: 1fr }
    .logo-slots { grid-template-columns: 1fr }
    .brand-logo-img { max-height: 36px }
}


/* v6.5: límites de tablas y gráficos para evitar crecimiento infinito */
.tbl-wrap { max-height:min(520px, 60vh) !important; overflow:auto !important; width:100%; }
.card canvas { display:block !important; width:100% !important; height:250px !important; max-height:250px !important; }
.card canvas.chart-small { height:210px !important; max-height:210px !important; }
@media(max-width:700px){ .card canvas { height:220px !important; max-height:220px !important; } }

.chart-box{position:relative;height:250px;max-height:250px;min-height:0;overflow:hidden;width:100%}.chart-box canvas{width:100%!important;height:100%!important;max-height:100%!important}
@media(max-width:700px){.chart-box{height:220px;max-height:220px}}

/* v6.5: tablas y graficas con dimensiones controladas */
.tbl-wrap{contain:layout paint;max-width:100%;max-height:min(520px,60vh)!important;overflow:auto!important}
.tbl-wrap table.tbl{margin:0!important;width:100%;max-width:100%}
.chart-box{contain:layout paint;position:relative;height:250px!important;max-height:250px!important;overflow:hidden;width:100%;max-width:100%}
.chart-box canvas{display:block!important;width:100%!important;height:100%!important;max-width:100%!important;max-height:250px!important}
@media(max-width:700px){.chart-box{height:220px!important;max-height:220px!important}}

/* ═══════════ v3: componentes tema-aware para nuevas páginas ═══════════ */

/* Popover form (dropdowns "Agendar cita", "+Agregar servicio", "Solicitar doc") */
.popover-form {
    position: absolute;
    right: 0;
    z-index: 20;
    background: var(--surf);
    color: var(--tx);
    padding: 16px;
    border-radius: 10px;
    border: 1px solid var(--brd);
    box-shadow: var(--card-shadow, 0 8px 32px rgba(0,0,0,.4));
    max-width: 92vw;
}
.popover-form label.field {
    color: var(--mut);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    display: block;
    margin-bottom: 4px;
}
.popover-form input, .popover-form select, .popover-form textarea {
    background: var(--surf2, var(--bg2));
    color: var(--tx);
    border: 1px solid var(--brd);
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
    font-family: inherit;
    font-size: .9rem;
}
.popover-form input:focus, .popover-form select:focus, .popover-form textarea:focus {
    outline: none;
    border-color: var(--vlt);
    box-shadow: 0 0 0 3px rgba(123,97,255,.15);
}

/* Card con tinte suave (tema-aware) para tarjetas de servicios y bloques resaltados */
.card-tint {
    background: var(--surf);
    border: 1px solid var(--brd);
}
[data-theme="light"] .card-tint { background: #FAFAFC; }

/* Bloque "notas cortas" del contacto */
.notes-block {
    background: var(--surf2, var(--bg2));
    color: var(--tx);
    border: 1px solid var(--brd);
    padding: 12px;
    border-radius: 8px;
    font-size: .9rem;
    white-space: pre-line;
}

/* Subtítulo de sección de form (Preferencias y origen) */
.form-section-title {
    margin: 20px 0 6px;
    color: var(--vlt);
    font-size: .85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--brd);
    padding-bottom: 6px;
    font-weight: 600;
}

/* Botón "Agendar cita" y "Solicitar documento" (usa gradient del tema) */
.btn-agendar {
    cursor: pointer;
    list-style: none;
    background: var(--grad);
    color: #fff;
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 700;
    font-size: .85rem;
    display: inline-block;
}
.btn-agendar::-webkit-details-marker { display: none; }
.btn-agendar-lg { padding: 10px 22px; border-radius: 8px; }

/* KPIs cards genéricas (usadas en documents.php) */
.card.kpi { padding: 14px 16px; display: block; }
.card.kpi .mut { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; }

/* Chip mini/tiny tema-aware */
.chip.mini, .chip.tiny {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.4;
}
.badge.tiny {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Header de páginas (services, documents) */
.hd { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.hd h1 { margin: 0; font-size: 1.4rem; color: var(--tx); }

/* Details/summary — quitar flecha nativa cuando usamos btn-agendar */
details.no-marker > summary { list-style: none; }
details.no-marker > summary::-webkit-details-marker { display: none; }
