/* ============================================
   TEMA.CSS - Loretapp
   Variables globales de color para ambos temas.
   Linkear en TODAS las páginas, ANTES del CSS específico.
   ============================================ */

/* ── MODO OSCURO (default) ── */
:root {
    /* Le dice al navegador qué paleta usar para controles nativos (el
       popup de <select>, scrollbars, date pickers, etc.). Sin esto, un
       navegador/SO en modo oscuro renderiza esos popups con su tema oscuro
       nativo pase lo que pase con nuestro CSS — mezclando fondo oscuro del
       SO con el texto oscuro de --text en modo claro, e ilegible (así se
       veían los combos de género/país/tamaño de letra en modo claro). */
    color-scheme: dark;

    --pink:        #ff1493;
    --pink-light:  #ff69b4;
    --pink-soft:   rgba(255, 20, 147, 0.12);

    --bg:          #0f0f0f;
    --bg2:         #1a1a1a;
    --bg3:         #222;
    --bg4:         #2a2a2a;

    --border:      #333;
    --border2:     #2a2a2a;

    --text:        #ffffff;
    --text2:       #cccccc;
    --text-muted:  #888888;
    --text-dim:    #555555;

    --navbar-bg:   #1a1a1a;
    --card-bg:     #1a1a1a;
    --input-bg:    #2a2a2a;

    --shadow:      rgba(0, 0, 0, 0.5);
    --shadow-pink: rgba(255, 20, 147, 0.3);

    --dropdown-bg: #0d0005;
    --dropdown-hover: rgba(206, 126, 186, 0.74);
    --dropdown-text: #ddd;
    --dropdown-icon: #611d41;
}

/* ── MODO CLARO ── */
:root.light-mode {
    color-scheme: light;

    --bg:          #faedf3;
    --bg2:         #fff6fa;
    --bg3:         #ffeaf3;
    --bg4:         #ffd6e8;

    --border:      #f0b8cc;
    --border2:     #f5d0de;

    --text:        #2a0a1a;
    --text2:       #5a2a3a;
    --text-muted:  #8a4a5a;
    --text-dim:    #aa8090;

    --navbar-bg:   #c8607a;
    --card-bg:     #fff6fa;
    --input-bg:    #fff0f7;

    --shadow:      rgba(100, 20, 50, 0.15);
    --shadow-pink: rgba(200, 60, 100, 0.25);

    --dropdown-bg:    #e8608a;
    --dropdown-hover: rgba(255, 150, 180, 0.5);
    --dropdown-text:  #fff;
    --dropdown-icon:  #fff;
}

/* ── FOCO DE TECLADO VISIBLE ──
   Muchos CSS de página quitan el outline por defecto (outline:none) sin poner
   ningún reemplazo, así que alguien navegando solo con teclado no ve dónde está
   parada. :focus-visible (no :focus) para que el contorno aparezca solo al
   navegar con teclado, no al hacer click con mouse. !important porque esos
   outline:none dispersos en cada static/css/*.css cargan DESPUÉS de tema.css. */
:focus-visible {
    outline: 2px solid var(--pink) !important;
    outline-offset: 2px !important;
}

/* Selección de texto (Ctrl+A / arrastrar con el mouse) — el azul por
   defecto del navegador no pega con la marca, se reemplaza por el rosa. */
::selection {
    background: var(--pink);
    color: #fff;
}

/* ── ESTILOS BASE QUE USAN LAS VARIABLES ── */
body {
    background: var(--bg) !important;
    color: var(--text) !important;
    font-family: 'Segoe UI', Arial, sans-serif;
    transition: background 0.3s, color 0.3s;
}

/* Navbar */
.top-bar {
    background: var(--navbar-bg) !important;
    border-bottom-color: var(--border) !important;
}
.nav-menu a { color: var(--text2) !important; }
.nav-menu a:hover { color: var(--pink) !important; }

/* ── VIEWS BADGE (ojito de vistas en portadas) — global ── */
.book-views-badge {
    position: absolute; bottom: 30px; right: 4px;
    background: rgba(0,0,0,0.62); color: #fff;
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 10px;
    display: flex; align-items: center; gap: 3px;
    pointer-events: none; z-index: 2;
    backdrop-filter: blur(3px);
}
.book-views-badge i { font-size: 9px; opacity: 0.85; }

/* ── CARD-PORTADA / HISTORIA-COVER views overlay ── */
.card-portada, .historia-cover { position: relative; }
.card-portada .views-overlay,
.historia-cover .views-overlay {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,0.62); color: #fff;
    font-size: 10px; font-weight: 600;
    padding: 2px 7px; border-radius: 10px;
    display: flex; align-items: center; gap: 3px;
    pointer-events: none; z-index: 2;
    backdrop-filter: blur(3px);
}
.card-portada .views-overlay i,
.historia-cover .views-overlay i { font-size: 9px; opacity: 0.85; }

/* ── PLAN BADGE NAVBAR — global ── */
.plan-badge-nav {
    padding: 7px 16px; border-radius: 24px;
    font-size: 13px; font-weight: 700; cursor: pointer;
}
.plan-badge-nav.plan-lector    { background:#2a2a2a; color:#ff69b4; border:1px solid #ff69b4; }
.plan-badge-nav.plan-escritor  { background:#2a2a2a; color:#9b59b6; border:1px solid #9b59b6; }
.plan-badge-nav.plan-vip       { background:#2a2a2a; color:#ffd700; border:1px solid #ffd700; }
.plan-badge-nav.plan-vip_platinum { background:#2a2a2a; color:#e5e4e2; border:1px solid #e5e4e2; }
.plan-badge-nav.plan-vip_mega  { background:linear-gradient(135deg,#1a0a2e,#2d0a4e); color:#cc88ff; border:1px solid #7f77dd; }

/* Search bar */
.search-bar {
    background: var(--input-bg) !important;
    border-color: var(--border2) !important;
}
.search-bar input { color: var(--text) !important; }
.search-bar input::placeholder { color: var(--text-dim) !important; }

/* iOS Safari hace zoom automático al enfocar un input/textarea con
   font-size menor a 16px — hay muchas copias sueltas de estilos de
   formulario por el sitio con tamaños chicos (13-14px), se fuerza acá
   globalmente en vez de perseguir cada una por separado. */
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="number"],
input:not([type]), textarea {
    font-size: 16px !important;
}

/* Dropdown */
.dropdown-menu {
    background: var(--dropdown-bg) !important;
    border-color: var(--border) !important;
    box-shadow: 0 8px 25px var(--shadow-pink) !important;
}
.dropdown-item { color: var(--dropdown-text) !important; }
.dropdown-item:hover { background: var(--dropdown-hover) !important; }
.dropdown-item i { color: var(--dropdown-icon) !important; }
.dropdown-item.logout { color: var(--pink) !important; }

/* Cards generales */
.book-card .book-title { color: var(--text) !important; }
.book-card .book-author { color: var(--text-muted) !important; }

/* ── CAMPANITA DE NOTIFICACIONES (navbar global) ── */
.notif-bell-wrap { position: relative; }
.notif-bell {
    width: 38px; height: 38px; border-radius: 10px;
    background: none; border: 1px solid var(--border, #333);
    color: var(--text2, #ccc); cursor: pointer; font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.2s; position: relative;
}
.notif-bell:hover { border-color: var(--pink, #ff1493); color: var(--pink, #ff1493); background: rgba(255,20,147,0.08); }
.notif-badge {
    position: absolute; top: -4px; right: -4px;
    background: var(--pink, #ff1493); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px; border-radius: 9px;
    display: none; align-items: center; justify-content: center;
    padding: 0 4px; border: 2px solid var(--bg, #0f0f0f);
}
.notif-badge.visible { display: flex; }
.notif-dropdown {
    position: absolute; top: calc(100% + 10px); right: 0;
    width: 360px; background: var(--bg2, #1a1a1a);
    border: 1px solid var(--border, #333); border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.6);
    z-index: 2000; display: none; overflow: hidden;
}
.notif-dropdown.show { display: block; animation: notifDropFade 0.2s ease; }
@keyframes notifDropFade { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: translateY(0); } }
.notif-drop-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid var(--border, #333);
}
.notif-drop-header h3 { font-size: 14px; font-weight: 700; color: var(--text, #fff); }
.notif-drop-actions { display: flex; gap: 8px; }
.btn-mark-all {
    font-size: 11px; font-weight: 600; color: var(--pink, #ff1493);
    background: none; border: none; cursor: pointer; padding: 0; transition: opacity 0.2s;
}
.btn-mark-all:hover { opacity: 0.7; }
.btn-ver-todas {
    font-size: 11px; font-weight: 600; color: var(--text-muted, #888);
    text-decoration: none; transition: color 0.2s;
}
.btn-ver-todas:hover { color: var(--pink, #ff1493); }
.notif-drop-lista { max-height: min(560px, calc(100vh - 160px)); overflow-y: auto; }
.notif-drop-lista::-webkit-scrollbar { width: 4px; }
.notif-drop-lista::-webkit-scrollbar-thumb { background: var(--border, #333); border-radius: 4px; }
.notif-drop-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer; transition: background 0.15s; text-decoration: none;
    color: inherit; position: relative;
}
.notif-drop-item:last-child { border-bottom: none; }
.notif-drop-item:hover { background: rgba(255,255,255,0.04); }
.notif-drop-item.no-leida { background: rgba(255,20,147,0.05); }
.notif-drop-item.no-leida::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0;
    width: 3px; background: var(--pink, #ff1493); border-radius: 0 2px 2px 0;
}
.notif-icono {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; background: var(--bg3, #222);
}
.notif-icono.like       { background: rgba(255,20,147,0.12); }
.notif-icono.comentario { background: rgba(59,130,246,0.12); }
.notif-icono.seguidor   { background: rgba(34,197,94,0.12); }
.notif-icono.capitulo   { background: rgba(124,58,237,0.22); box-shadow: inset 0 0 0 1.5px rgba(124,58,237,0.55); }
:root.light-mode .notif-icono.capitulo { background: rgba(220,38,38,0.14); box-shadow: inset 0 0 0 1.5px rgba(220,38,38,0.55); }
.notif-icono.anuncio    { background: rgba(245,158,11,0.12); }
.notif-cuerpo { flex: 1; min-width: 0; }
.notif-texto { font-size: 13px; color: var(--text, #fff); line-height: 1.45; margin-bottom: 3px; }
.notif-fecha { font-size: 11px; color: var(--text-muted, #888); }
.notif-drop-footer {
    border-top: 1px solid var(--border, #333); padding: 12px 18px; text-align: center;
}
.notif-drop-footer a { font-size: 12px; color: var(--pink, #ff1493); text-decoration: none; font-weight: 600; }
.notif-drop-footer a:hover { opacity: 0.8; }
.notif-drop-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; padding: 32px 18px; color: var(--text-muted, #888);
    font-size: 13px; text-align: center;
}
.notif-drop-empty i { font-size: 24px; opacity: 0.4; }
.notif-drop-avatar {
    width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.notif-drop-avatar-ini {
    background: linear-gradient(135deg, #682448, #ff69b4);
    display: flex; align-items: center; justify-content: center;
    font-size: 15px; font-weight: 700; color: #fff;
}

/* Category pills */
.cat-pill {
    background: var(--bg2) !important;
    border-color: var(--border) !important;
    color: var(--text2) !important;
}
.cat-pill:hover { border-color: var(--pink) !important; color: var(--pink) !important; }
.cat-pill.active { background: var(--pink) !important; border-color: var(--pink) !important; color: #fff !important; }

/* Sidebar cards / secciones */
.sidebar-card,
.config-seccion,
.seccion,
.capitulo-item {
    background: var(--card-bg) !important;
    border-color: var(--border2) !important;
}

/* Footer */
footer {
    border-top-color: var(--border) !important;
    color: var(--text-muted) !important;
}
.footer-links a { color: var(--text-muted) !important; }
.footer-links a:hover { color: var(--pink) !important; }

/* Inputs y selects */
input, textarea, select {
    background: var(--input-bg) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
input::placeholder, textarea::placeholder { color: var(--text-dim) !important; }
input:focus, textarea:focus, select:focus { border-color: var(--pink) !important; }

/* Hero (inicio) */
:root.light-mode .hero {
    background:
        linear-gradient(180deg, rgba(120, 40, 70, 0.4) 0%, rgba(250, 237, 243, 0.55) 100%),
        url('/static/img/hero-bg.jpg.jpeg') 50% 38%/cover no-repeat !important;
}
:root.light-mode .hero p { color: var(--text2) !important; }
:root.light-mode .hero h1,
:root.light-mode .hero h1 .highlight {
    text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 2px 14px rgba(255,255,255,0.7);
}
:root.light-mode .hero p {
    text-shadow: 0 1px 6px rgba(255,255,255,0.85);
}

/* Explorar */
:root.light-mode .explorar-header {
    background:
        linear-gradient(180deg, rgba(120, 40, 70, 0.35) 0%, rgba(250, 237, 243, 0.75) 100%),
        url('/static/img/explorar-bg.png') 50% 30%/cover no-repeat !important;
}
:root.light-mode .explorar-header h1 {
    text-shadow: 0 1px 4px rgba(255,255,255,0.9), 0 2px 14px rgba(255,255,255,0.7);
}
:root.light-mode .explorar-header p {
    color: var(--text2) !important;
    text-shadow: 0 1px 6px rgba(255,255,255,0.85);
}

/* Vaerin Originals */
:root.light-mode .vaerin-originals {
    background: linear-gradient(135deg, #ffeaf3, #ffd6e8) !important;
    border-color: #f0b8cc !important;
}
:root.light-mode .originals-text h3 { color: #2a0a1a !important; }
:root.light-mode .originals-text p { color: #cc3366 !important; }

/* Avatar inicial */
.initial-avatar-small {
    background: linear-gradient(135deg, #682448, #ff69b4) !important;
    color: #fff !important;
}
:root.light-mode .initial-avatar-small {
    border: 2px solid rgba(255,255,255,0.4);
    box-shadow: 0 2px 8px var(--shadow-pink);
}

/* Transición suave en todo */
*, *::before, *::after {
    transition: background-color 0.25s, border-color 0.25s, color 0.25s;
}
/* Excepciones donde la transición se ve rara */
img, .carousel, .book-card img { transition: transform 0.25s, box-shadow 0.25s !important; }

/* ============================================
   INSIGNIAS INLINE — compartido en toda la app
   (comentarios, muro, buscador, tarjetas de historia/autor)
   ============================================ */
.badge-inline {
    display: inline-block !important;
    width: 22px !important;
    height: 22px !important;
    vertical-align: middle;
    margin-left: 5px;
    position: relative;
    cursor: pointer;
}
/* Muchas tarjetas (book-card, historia-card, etc.) traen su propia regla genérica
   "img { width/height }" con la misma especificidad — forzamos el tamaño de la
   insignia para que nunca la infle a como si fuera la portada de la tarjeta. */
.badge-inline img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border-radius: 0 !important;
    border: none !important;
    filter: drop-shadow(0 1px 4px rgba(0,0,0,0.5));
}
.badge-inline .badge-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 5px 10px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
.badge-inline:hover .badge-tooltip { opacity: 1; }
.badge-inline-img { width: 18px !important; height: 18px !important; object-fit: contain !important; vertical-align: middle; border-radius: 3px; flex-shrink: 0; margin-left: 4px; }

.tick-verificado {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-left: 3px;
    position: relative;
    cursor: default;
    flex-shrink: 0;
}
.tick-verificado img { width: 20px !important; height: 20px !important; object-fit: contain; transition: transform 0.15s; filter: drop-shadow(0 1px 3px rgba(231,76,60,0.6)); }
.tick-verificado:hover img { transform: scale(1.2); }
.tick-verificado::after {
    content: 'Verificado +18 ✓';
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a1a;
    border-radius: 6px;
    padding: 4px 9px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 600;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
    border: 1px solid #e74c3c;
    color: #e74c3c;
}

/* ── Autocompletado de @menciones (mention_autocomplete.js) ── */
.mention-dropdown {
    position: absolute;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 10px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 9999;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.mention-dropdown-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px; cursor: pointer; font-size: 13px; color: #ddd;
}
.mention-dropdown-item img,
.mention-avatar-inicial {
    width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
}
.mention-avatar-inicial {
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #ff1493, #ff69b4); color: #fff;
    font-weight: 700; font-size: 11px;
}
.mention-dropdown-item:hover,
.mention-dropdown-item.activo { background: rgba(255,255,255,0.08); }
:root.light-mode .mention-dropdown { background: #fff; border-color: #ddd; }
:root.light-mode .mention-dropdown-item { color: #222; }
:root.light-mode .mention-dropdown-item:hover,
:root.light-mode .mention-dropdown-item.activo { background: rgba(0,0,0,0.05); }
.tick-verificado:hover::after { opacity: 1; }
.mention-link {
    color: rgb(230, 91, 195);
    text-decoration: none;
    font-weight: 600;
}
.mention-link:hover { text-decoration: underline; }

.btn-emoji-toggle {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0 2px;
    opacity: .6;
    transition: opacity .2s;
    line-height: 1;
    flex-shrink: 0;
}
.btn-emoji-toggle:hover { opacity: 1; }

/* ── PICKER COMPARTIDO DE EMOJI/STICKERS (emoji_sticker_picker.js) ──
   Un solo popover reusado en Tavia, comentarios, Muro y Buzón. */
.esp-picker {
    display: none;
    flex-direction: column;
    width: 340px;
    max-height: 380px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 12px 32px var(--shadow);
    z-index: 3000;
    overflow: hidden;
}
.esp-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.esp-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 10px 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.esp-tab:hover { color: var(--text); }
.esp-tab.activa { color: var(--pink); border-bottom-color: var(--pink); }

.esp-panel {
    overflow-y: auto;
    padding: 8px;
}
.esp-panel-emoji {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.esp-emoji-item {
    background: none;
    border: none;
    font-size: 19px;
    padding: 5px 0;
    cursor: pointer;
    border-radius: 6px;
    line-height: 1;
}
.esp-emoji-item:hover { background: rgba(255,255,255,0.08); }
:root.light-mode .esp-emoji-item:hover { background: rgba(0,0,0,0.06); }

.esp-sticker-grupo { margin-bottom: 10px; }
.esp-sticker-grupo:last-child { margin-bottom: 0; }
.esp-sticker-grupo-titulo {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 2px 4px 6px;
}
.esp-sticker-grupo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.esp-sticker-item {
    background: none;
    border: none;
    padding: 3px;
    border-radius: 8px;
    cursor: pointer;
    aspect-ratio: 1;
    position: relative;
}
.esp-sticker-item:hover { background: rgba(255,255,255,0.08); }
:root.light-mode .esp-sticker-item:hover { background: rgba(0,0,0,0.06); }
.esp-sticker-item img { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Pack no comprado: sigue visible (vidriera), pero atenuado + candado --
   tocar uno manda a comprarlo en Tienda en vez de insertar (ver
   emoji_sticker_picker.js). */
.esp-sticker-item-bloqueado img { opacity: 0.4; }
.esp-sticker-lock {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 13px; text-shadow: 0 1px 3px rgba(0,0,0,0.7); pointer-events: none;
}

/* Sticker ya insertado dentro de un comentario/mensaje pintado */
img.sticker-inline {
    width: 104px;
    height: 104px;
    object-fit: contain;
    vertical-align: middle;
    margin: 2px 0;
    display: inline-block;
}
