/* ============================================================
   Crónicas de la Cripta — Overrides Bootstrap 5.3
   ============================================================ */

/* ── Variables de terror ─────────────────────────────────── */
:root {
  --blood:      #8b0000;
  --blood-l:    #a50000;
  --blood-d:    #5a0000;
  --bone:       #e8e0d0;
  --ash:        #a09890;
  --ghost:      #6a6060;
  --surface:    #111111;
  --card:       #1a1a1a;
  --border:     #2a2a2a;
  --muted-c:    #3a3a3a;
  --font-serif: 'Crimson Text', Georgia, serif;
  --font-mono:  'Courier Prime', Courier, monospace;
}

/* ── Base ────────────────────────────────────────────────── */
body { font-family: 'Inter', system-ui, sans-serif; }
::selection { background: var(--blood); color: var(--bone); }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #0a0a0a; }
::-webkit-scrollbar-thumb { background: var(--muted-c); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--blood); }
a { color: var(--bone); }
a:hover { color: var(--blood-l); }
.font-mono { font-family: var(--font-mono) !important; }
.font-serif { font-family: var(--font-serif) !important; }

/* ── Bootstrap overrides ─────────────────────────────────── */
/* Botón primario → rojo sangre */
.btn-primary { background: var(--blood); border-color: var(--blood); color: var(--bone); }
.btn-primary:hover, .btn-primary:focus { background: var(--blood-l); border-color: var(--blood-l); color: var(--bone); }
.btn-danger { background: var(--blood-d); border-color: var(--blood); }
.btn-danger:hover { background: var(--blood); border-color: var(--blood-l); }

/* Cards oscuras */
.card { background: var(--card); border-color: var(--border); }
.card-body { background: var(--card); }

/* Forms */
.form-control, .form-select {
    background: var(--surface);
    border-color: var(--border);
    color: var(--bone);
}
.form-control:focus, .form-select:focus {
    background: var(--surface);
    border-color: var(--ash);
    color: var(--bone);
    box-shadow: 0 0 0 .2rem rgba(139,0,0,.25);
}
.form-control::placeholder { color: var(--ghost); }

/* Navbar links */
.navbar .nav-link { color: var(--ash) !important; font-size: .85rem; transition: color .2s; }
.navbar .nav-link:hover { color: var(--bone) !important; }
.navbar-toggler-icon { filter: invert(1); }

/* Badges */
.badge.bg-blood { background: var(--blood-d) !important; color: var(--blood-l); }

/* Tables */
.table-dark { --bs-table-bg: var(--surface); --bs-table-border-color: var(--border); }
.table-dark th { color: var(--ghost); font-family: var(--font-mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; }
.table-hover > tbody > tr:hover > * { background: var(--card); }

/* Accordion admin */
.accordion-button { background: var(--surface); color: var(--bone); }
.accordion-button:not(.collapsed) { background: var(--card); color: var(--bone); box-shadow: none; }
.accordion-button::after { filter: invert(1); }
.accordion-item { background: var(--surface); border-color: var(--border); }
.accordion-body { background: var(--card); }

/* Alert */
.alert { border-radius: 4px; font-size: .875rem; }

/* Pagination */
.pagination .page-link { background: var(--surface); border-color: var(--border); color: var(--ash); }
.pagination .page-link:hover { background: var(--card); color: var(--bone); }
.pagination .page-item.active .page-link { background: var(--blood); border-color: var(--blood); color: var(--bone); }
.pagination .page-item.disabled .page-link { background: var(--surface); color: var(--ghost); }

/* ── Hero ────────────────────────────────────────────────── */
.hero-section {
    padding: 3.5rem 0 2.5rem;
    text-align: center;
    border-bottom: 1px solid var(--border);
    background: repeating-linear-gradient(0deg, transparent, transparent 40px, rgba(255,255,255,.008) 40px, rgba(255,255,255,.008) 41px);
}
.hero-img {
    max-width: min(380px, 75vw);
    height: auto;
    filter: drop-shadow(0 4px 24px rgba(139,0,0,.35));
    animation: hero-float 6s ease-in-out infinite;
}
@keyframes hero-float {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-8px); }
}
.hero-title { font-family: var(--font-serif); font-size: clamp(1.8rem, 5vw, 2.8rem); color: var(--bone); }
.hero-sub   { font-family: var(--font-mono); font-size: .85rem; color: var(--ghost); }

/* ── Story cards ─────────────────────────────────────────── */
.story-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1.25rem;
    transition: border-color .2s, background .2s;
    display: block;
    text-decoration: none;
    color: var(--bone);
}
.story-card:hover { border-color: var(--muted-c); background: var(--surface); color: var(--bone); }
.story-card-title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    color: var(--bone);
    margin-bottom: .5rem;
    line-height: 1.3;
}
.story-card:hover .story-card-title { color: var(--blood-l); }
.story-card-excerpt {
    font-size: .875rem;
    color: var(--ash);
    line-height: 1.6;
    margin-bottom: .75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.story-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: .5rem; }
.story-card-top .story-card-title { margin-bottom: 0; flex: 1; }
.story-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; font-size: .75rem; font-family: var(--font-mono); color: var(--ghost); }
.story-tags { display: flex; gap: .375rem; flex-wrap: wrap; margin-top: .625rem; }
.story-tag { background: var(--surface); border: 1px solid var(--border); color: var(--ash); font-size: .65rem; font-family: var(--font-mono); padding: .15rem .5rem; border-radius: 3px; }

/* ── Stars ───────────────────────────────────────────────── */
.stars-display { display: flex; align-items: center; gap: 1px; flex-shrink: 0; white-space: nowrap; }
.stars-display .star { font-size: .875rem; line-height: 1; }
.star-filled  { color: #f59e0b; }
.star-half    { color: #d97706; }
.star-empty   { color: var(--muted-c); }
.stars-avg { font-family: var(--font-mono); font-size: .7rem; color: var(--ash); margin-left: .25rem; }
.votes-count { font-size: .7rem; color: var(--ghost); font-family: var(--font-mono); }

/* ── Rating widget ───────────────────────────────────────── */
.rating-widget { margin: 2rem 0 1rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; text-align: center; }
.rating-label { font-family: var(--font-mono); font-size: .8rem; color: var(--ash); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 1rem; }
.stars-interactive { display: flex; align-items: center; justify-content: center; gap: .25rem; margin-bottom: .875rem; }
.star-btn { background: none; border: none; font-size: 2rem; color: var(--muted-c); cursor: pointer; transition: color .1s, transform .1s; padding: 0 .1rem; line-height: 1; }
.star-btn:hover, .star-btn.star-hover { color: #f59e0b; transform: scale(1.15); }
.star-btn.star-active { color: #f59e0b; }
.rating-summary { font-family: var(--font-mono); font-size: .8rem; color: var(--ghost); min-height: 1.2em; }

/* ── Filters & search ────────────────────────────────────── */
.search-by-select { background: var(--card); color: var(--ash); border-color: var(--border); border-right: none; border-radius: 4px 0 0 4px; min-width: 130px; }
.search-input { border-radius: 0 !important; border-left: none !important; border-right: none !important; }
.search-btn { background: var(--blood); border: 1px solid var(--blood); border-radius: 0 4px 4px 0; color: var(--bone); padding: 0 1rem; cursor: pointer; transition: background .2s; display: flex; align-items: center; }
.search-btn:hover { background: var(--blood-l); }
.active-filter-chip { background: var(--blood-d); color: var(--blood-l); border: 1px solid var(--blood-d); font-family: var(--font-mono); font-size: .7rem; padding: .15rem .625rem; border-radius: 20px; }

/* ── Ad slot ─────────────────────────────────────────────── */
.ad-slot { margin: 1.5rem 0; text-align: center; }

/* ── Story Chat (WhatsApp narrator) ──────────────────────── */
.story-chat-page {
    min-height: calc(100vh - 56px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.5rem 1rem 0;
    background: #000;
}
.story-chat-wrap {
    width: 100%;
    max-width: 680px;
    background: #0a0a0a;
    border-radius: 10px 10px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    height: calc(100vh - 56px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.story-chat-header {
    display: flex;
    align-items: center;
    gap: .875rem;
    padding: .75rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 56px;
    z-index: 10;
}
.story-chat-back { font-family: var(--font-mono); font-size: .75rem; color: var(--ghost); white-space: nowrap; flex-shrink: 0; text-decoration: none; }
.story-chat-back:hover { color: var(--ash); }
.story-chat-contact { display: flex; align-items: center; gap: .625rem; flex: 1; min-width: 0; }
.story-chat-avatar { position: relative; width: 36px; height: 36px; background: var(--blood-d); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: .875rem; color: var(--blood-l); flex-shrink: 0; }
.story-chat-online { position: absolute; bottom: 1px; right: 1px; width: 8px; height: 8px; background: #4ade80; border-radius: 50%; border: 2px solid var(--surface); animation: pulse 2s infinite; }
.story-chat-name { font-size: .875rem; font-weight: 500; color: var(--bone); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.story-chat-status { font-size: .7rem; font-family: var(--font-mono); color: var(--blood-l); animation: pulse 1.5s infinite; white-space: nowrap; }
.story-chat-meta-right { display: flex; gap: .375rem; flex-shrink: 0; }
.story-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem .875rem;
    display: flex;
    flex-direction: column;
    gap: .625rem;
    background: repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(255,255,255,.006) 28px, rgba(255,255,255,.006) 29px), #0a0a0a;
}
.chat-date-divider { display: flex; align-items: center; justify-content: center; margin: .5rem 0; }
.chat-date-divider span { background: var(--surface); border: 1px solid var(--border); color: var(--ghost); font-family: var(--font-mono); font-size: .65rem; padding: .2rem .75rem; border-radius: 10px; }
.chat-system-msg { text-align: center; font-family: var(--font-serif); font-size: 1.1rem; color: var(--ash); font-style: italic; padding: .5rem 1rem; margin: .5rem 0 1rem; }
.msg { display: flex; max-width: 85%; }
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; }
.msg-bubble { padding: .75rem 1rem; border-radius: 6px; line-height: 1.6; }
.msg-bot .msg-bubble { background: var(--card); border: 1px solid var(--border); font-family: var(--font-serif); color: var(--bone); }
.msg-user .msg-bubble { background: var(--blood-d); border: 1px solid var(--blood-d); font-family: var(--font-mono); color: var(--bone); font-size: .8rem; border-radius: 12px 2px 12px 12px; }

/* Burbujas de narración — tamaño aumentado */
.story-msg .msg-bubble {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 2px 12px 12px 12px;
    padding: .75rem 1rem;
    font-family: var(--font-serif);
    font-size: 1.4rem;        /* Desktop */
    line-height: 1.85;
    color: var(--bone);
    max-width: 88%;
    position: relative;
    white-space: pre-wrap;
    word-break: break-word;
}
.story-msg .msg-bubble::before {
    content: '';
    position: absolute;
    top: 0; left: -6px;
    border: 6px solid transparent;
    border-top-color: var(--border);
    border-right-color: var(--border);
}
.chat-typing-indicator { display: flex; align-items: center; gap: 4px; padding: .5rem .75rem; }
.chat-typing-indicator span { display: block; width: 6px; height: 6px; background: var(--ghost); border-radius: 50%; animation: typing-dot 1.2s infinite; }
.chat-typing-indicator span:nth-child(2) { animation-delay: .2s; }
.chat-typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-dot { 0%,60%,100%{opacity:.3;transform:translateY(0)} 30%{opacity:1;transform:translateY(-4px)} }
.story-chat-bottom { border-top: 1px solid var(--border); background: var(--surface); padding: .75rem 1rem; min-height: 60px; display: flex; align-items: center; justify-content: center; }
.story-chat-input-area { width: 100%; display: flex; justify-content: center; }
.story-read-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .625rem 2rem; background: var(--blood); color: var(--bone); border: none; border-radius: 20px; font-family: var(--font-mono); font-size: .8rem; font-weight: 600; letter-spacing: .05em; cursor: pointer; transition: background .2s, transform .1s; }
.story-read-btn:hover { background: var(--blood-l); transform: scale(1.03); }
.chat-opt-label { font-family: var(--font-mono); font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ghost); padding: 0 .25rem .25rem; }
.chat-opt-btn { width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); color: var(--bone); padding: .75rem 1rem; border-radius: 8px; font-size: 1rem; font-family: 'Inter', sans-serif; cursor: pointer; transition: border-color .15s, background .15s; line-height: 1.4; }
.chat-opt-btn:hover { border-color: var(--blood-d); background: rgba(139,0,0,.08); }
.chat-opt-btn:active { transform: scale(.98); }
.cursor { display: inline-block; width: .6em; height: 1em; background: var(--blood); vertical-align: text-bottom; animation: blink 1s step-end infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* Responsive chat */
@media (max-width: 768px) {
    .story-chat-page { padding: 0; }
    .story-chat-wrap { border-radius: 0; border-left: none; border-right: none; height: calc(100vh - 56px); }
    .story-msg .msg-bubble { font-size: 1.35rem; max-width: 94%; }
    .story-chat-meta-right { display: none; }
}

/* ── Auth pages ──────────────────────────────────────────── */
.auth-page { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 2rem 1.25rem; }
.auth-box { width: 100%; max-width: 420px; }
.auth-title { font-family: var(--font-serif); font-size: 1.6rem; text-align: center; margin: .5rem 0 1.5rem; }
.auth-alt { text-align: center; font-family: var(--font-mono); font-size: .8rem; color: var(--ghost); margin-top: 1rem; }
.auth-alt a { color: var(--ash); }

/* ── Premium card ────────────────────────────────────────── */
.premium-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 2.5rem; text-align: center; }
.premium-price { font-family: var(--font-serif); font-size: 3rem; color: var(--bone); margin: 1rem 0 .25rem; }
.premium-period { font-family: var(--font-mono); font-size: .8rem; color: var(--ghost); margin-bottom: 2rem; }
.premium-features { list-style: none; text-align: left; margin-bottom: 2rem; padding: 0; }
.premium-features li { padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; display: flex; gap: .75rem; }
.premium-features li::before { content: '▓'; color: var(--blood); font-size: .7rem; flex-shrink: 0; margin-top: .25rem; }

/* ── Admin sidebar ───────────────────────────────────────── */
.admin-sidebar { background: var(--surface); border-right: 1px solid var(--border) !important; }
.admin-sidebar .nav-link { color: var(--ghost); font-family: var(--font-mono); font-size: .8rem; transition: color .2s, background .2s; }
.admin-sidebar .nav-link:hover { color: var(--bone); background: var(--card); }
.admin-sidebar .nav-link.active { color: var(--bone); background: var(--card); border-left: 2px solid var(--blood); }
@media (max-width: 768px) {
    .admin-sidebar { min-width: 100% !important; border-right: none !important; border-bottom: 1px solid var(--border); flex-direction: row !important; overflow-x: auto; }
    .admin-sidebar ul { flex-direction: row !important; }
}

/* ── Audio controls ──────────────────────────────────────── */
.audio-toggle-btn { background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--ghost); cursor: pointer; padding: .3rem .5rem; display: flex; align-items: center; justify-content: center; transition: color .2s, border-color .2s; }
.audio-toggle-btn:hover { color: var(--ash); border-color: var(--ash); }
.audio-toggle-btn.audio-active { color: var(--blood-l); border-color: var(--blood-d); }
.vol-slider { -webkit-appearance: none; appearance: none; width: 72px; height: 3px; background: var(--muted-c); border-radius: 2px; outline: none; cursor: pointer; }
.vol-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; background: var(--bone); cursor: pointer; }
.vol-slider::-webkit-slider-thumb:hover { background: var(--blood-l); }
@media (max-width: 768px) { .vol-slider { display: none; } }

/* ── Buy Me a Coffee ─────────────────────────────────────── */
#bmc-wbtn, .bmc-btn-container { display: inline-flex !important; }
.bmc-btn { transform: scale(0.85); transform-origin: right center; }

/* ── Divider ─────────────────────────────────────────────── */
.cripta-divider { display: flex; align-items: center; gap: 1rem; margin: 2rem 0; }
.cripta-divider::before, .cripta-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.cripta-divider-text { font-family: var(--font-mono); font-size: .7rem; color: var(--blood); }

/* ── Badges personalizados ───────────────────────────────── */
.badge-pub { background: rgba(42,90,58,.3); color: #4ade80; border: 1px solid #2a5a3a; }
.badge-pen { background: var(--muted-c); color: var(--ash); border: 1px solid var(--border); }
.badge-rej { background: rgba(139,0,0,.2); color: var(--blood-l); border: 1px solid var(--blood-d); }
.badge-dft { background: var(--surface); color: var(--ghost); border: 1px solid var(--border); }

/* ── Scrollbar para mensajes ─────────────────────────────── */
.story-chat-messages::-webkit-scrollbar { width: 3px; }
.story-chat-messages::-webkit-scrollbar-thumb { background: var(--muted-c); border-radius: 2px; }
