/* ============================================
   UX Improvements - Apotoxin Fansub
   Bootstrap 5.3 Native Menu
   ============================================ */

/* === Base === */
html { scroll-behavior: smooth; }
img:not([height]) { max-width: 100%; height: auto; }
:focus-visible { outline: 2px solid #28a745; outline-offset: 2px; }

/* === Topbar === */
.aptx-topbar {
    background: #1a1d21;
    padding: 6px 0;
}
.aptx-topbar a img { opacity: 0.85; transition: opacity 0.2s; }
.aptx-topbar a img:hover { opacity: 1; }

/* === Navbar === */
.aptx-navbar {
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0;
    z-index: 1030;
    border-bottom: 3px solid #28a745;
}
.aptx-navbar .navbar-brand img { height: 40px; }
.aptx-navbar .nav-link {
    font-size: 15px;
    font-weight: 600;
    color: #2c3e50;
    padding: 14px 18px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s, background 0.2s;
}
.aptx-navbar .nav-link:hover,
.aptx-navbar .nav-link:focus { color: #28a745; background: rgba(40,167,69,0.05); }
.aptx-navbar .dropdown-menu {
    border: none;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-radius: 8px;
    padding: 8px 0;
    margin-top: 4px;
}
.aptx-navbar .dropdown-item {
    font-size: 13px;
    padding: 6px 16px;
    transition: background 0.15s;
}
.aptx-navbar .dropdown-item:hover { background: #f0f9f0; color: #28a745; }

/* Desktop: indicador superior animado en nav links */
@media (min-width: 992px) {
    .aptx-navbar .nav-link {
        position: relative;
    }
    .aptx-navbar .nav-link::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        right: 50%;
        height: 3px;
        background: #28a745;
        border-radius: 0 0 4px 4px;
        transition: left 0.22s ease, right 0.22s ease;
    }
    .aptx-navbar .nav-link:hover::before,
    .aptx-navbar .nav-link.show::before {
        left: 10px;
        right: 10px;
    }
}

/* Submenus (dropend) - show on hover, positioned to the right */
@media (min-width: 992px) {
    .aptx-navbar .dropend .dropdown-menu {
        position: absolute;
        top: 0;
        left: 100%;
        margin-top: 0;
        margin-left: -2px;
        padding-left: 4px;
    }
    .aptx-navbar .dropend .dropdown-toggle::after {
        content: "›";
        border: none;
        font-size: 1.2rem;
        vertical-align: middle;
        margin-left: auto;
        float: right;
    }
    /* Prevent dropdown from closing when moving mouse */
    .aptx-navbar .dropdown-menu { margin-top: 0; padding-top: 6px; }
    .aptx-navbar .nav-item.dropdown { padding-bottom: 4px; }
    .aptx-navbar .dropdown-menu::before {
        content: '';
        position: absolute;
        top: -10px;
        left: 0;
        right: 0;
        height: 10px;
    }

    /* Dropdown items: transición suave con icono coloreado */
    .aptx-navbar .dropdown-item {
        display: flex;
        align-items: center;
        gap: 8px;
        transition: background 0.15s, color 0.15s, padding-left 0.15s;
    }
    .aptx-navbar .dropdown-item .bi {
        font-size: 0.9rem;
        width: 1rem;
        text-align: center;
        flex-shrink: 0;
        color: #adb5bd;
        transition: color 0.15s;
    }
    .aptx-navbar .dropdown-item:hover .bi { color: #28a745; }
    .aptx-navbar .dropdown-item:hover { padding-left: 20px; }
}

/* Sticky behavior */
.aptx-navbar.sticky-top {
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* Dark mode toggle */
.aptx-dark-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.aptx-dark-toggle input { display: none; }
.aptx-dark-toggle .slider {
    width: 36px;
    height: 20px;
    background: #ccc;
    border-radius: 10px;
    position: relative;
    transition: background 0.3s;
}
.aptx-dark-toggle .slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}
.aptx-dark-toggle input:checked + .slider { background: #28a745; }
.aptx-dark-toggle input:checked + .slider::before { transform: translateX(16px); }

/* === Embed responsive (BS4 compatibility + BS5) === */
.embed-responsive { position: relative; display: block; width: 100%; padding: 0; overflow: hidden; }
.embed-responsive-16by9 { padding-bottom: 56.25%; }
.embed-responsive-4by3 { padding-bottom: 75%; }
.embed-responsive iframe,
.embed-responsive video,
.embed-responsive .embed-responsive-item { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: 0; }

/* Hide embed container when iframe has no src */
.embed-responsive iframe[src=""],
.embed-responsive iframe:not([src]) { display: none; }
.embed-responsive:has(iframe[src=""]),
.embed-responsive:has(iframe:not([src])) { padding-bottom: 0; min-height: 0; }

/* Force hide empty embed containers on all devices */
.embed-responsive-16by9:empty { padding-bottom: 0; }
.embed-responsive-16by9 { max-height: 0; overflow: hidden; transition: max-height 0.3s; }
.embed-responsive-16by9:has(iframe[src]) { max-height: 1000px; padding-bottom: 56.25%; }
.embed-responsive-16by9.active { max-height: 1000px; padding-bottom: 56.25%; }

/* === Cards === */
.card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
.card:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.15); }
.card-img-top { max-height: 300px; object-fit: cover; }

/* === Buttons === */
.btn { transition: all 0.2s ease; border-radius: 8px; font-weight: 600; }
.btn:hover { transform: translateY(-1px); }
.btn-block { display: block; width: 100%; }

.btn-success {
    background: #28a745;
    border-color: #28a745;
    color: #fff !important;
}
.btn-success:hover { background: #218838; border-color: #218838; color: #fff !important; }

.btn-info {
    background: #6f42c1;
    border-color: #6f42c1;
    color: #fff !important;
}
.btn-info:hover { background: #5a32a3; border-color: #5a32a3; color: #fff !important; }

.btn-warning {
    background: #ffc107;
    border-color: #ffc107;
    color: #333 !important;
}
.btn-warning:hover { background: #e0a800; border-color: #e0a800; }

.btn-danger {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff !important;
}
.btn-danger:hover { background: #c82333; border-color: #c82333; }

.btn-lg {
    padding: 10px 28px;
    font-size: 1rem;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.8rem;
}

/* === Tables === */
table img:not([height]), .table img:not([height]) { max-height: 50px; width: auto; }
td img:not([height]) { max-height: 50px; max-width: 50px; }

/* === Progress === */
.progress-bar { transition: width 0.6s ease; }

/* === Forms === */
#myInput.form-control-sm { border: 1px solid #dee2e6; border-radius: 6px; transition: border-color 0.2s; }
#myInput.form-control-sm:focus { border-color: #28a745; box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.15); }
.form-check-input:checked { background-color: #28a745; border-color: #28a745; }

/* === Dark mode (BS5.3) === */
[data-bs-theme="dark"] body, body.dark-mode { background-color: #1a1d21; color: #e0e0e0; }
[data-bs-theme="dark"] .aptx-navbar, body.dark-mode .aptx-navbar { background: #2d3238; }
[data-bs-theme="dark"] .aptx-navbar .nav-link, body.dark-mode .aptx-navbar .nav-link { color: #e0e0e0; }
[data-bs-theme="dark"] .aptx-navbar .nav-link:hover { color: #28a745; }
[data-bs-theme="dark"] .aptx-navbar .dropdown-menu, body.dark-mode .dropdown-menu { background: #2d3238; border-color: #3d4349; }
[data-bs-theme="dark"] .aptx-navbar .dropdown-item, body.dark-mode .dropdown-item { color: #e0e0e0; }
[data-bs-theme="dark"] .aptx-navbar .dropdown-item:hover, body.dark-mode .dropdown-item:hover { background: #3d4349; color: #28a745; }
[data-bs-theme="dark"] .card, body.dark-mode .card { background-color: #2d3238; border-color: #3d4349; }
[data-bs-theme="dark"] .card-header, body.dark-mode .card-header { background-color: #343a40; color: #fff; }
[data-bs-theme="dark"] .footer, body.dark-mode .footer { background-color: #111 !important; }
[data-bs-theme="dark"] h1, [data-bs-theme="dark"] h2, [data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] h5, [data-bs-theme="dark"] h6 { color: #fff; }
[data-bs-theme="dark"] .bg-secondary, body.dark-mode .bg-secondary { background-color: #2d3238 !important; }
[data-bs-theme="dark"] .bg-light, body.dark-mode .bg-light { background-color: #2d3238 !important; color: #e0e0e0; }
[data-bs-theme="dark"] .text-muted, body.dark-mode .text-muted { color: #adb5bd !important; }
[data-bs-theme="dark"] .modal-content, body.dark-mode .modal-content { background-color: #2d3238; color: #e0e0e0; }
[data-bs-theme="dark"] a, body.dark-mode a { color: #6ea8fe; }
[data-bs-theme="dark"] .entry-detail, body.dark-mode .entry-detail { background: #2d3238 !important; color: #e0e0e0; }
[data-bs-theme="dark"] table, body.dark-mode table { background: #2d3238; color: #e0e0e0; }

/* === Scrollbar === */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #28a745; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #218838; }

/* === Mobile === */
@media (max-width: 991px) {
    .aptx-navbar .navbar-collapse { padding: 0.5rem 0 1rem; }

    /* Nav items: separador y padding generoso */
    .aptx-navbar .nav-item { border-bottom: 1px solid rgba(0,0,0,0.05); }
    .aptx-navbar .nav-item:last-child { border-bottom: none; }

    /* Nav links: flex con icono coloreado */
    .aptx-navbar .nav-link {
        padding: 12px 4px;
        border-bottom: none;
        display: flex !important;
        align-items: center;
    }
    .aptx-navbar .nav-link .bi {
        font-size: 1.1rem;
        color: #28a745;
        width: 1.6rem;
        text-align: center;
        flex-shrink: 0;
    }
    .aptx-navbar .nav-link:hover .bi { color: #1a7a35; }

    /* Dropdown: sangría con acento verde */
    .aptx-navbar .dropdown-menu {
        box-shadow: none;
        background: #f7fdf8;
        border-left: 3px solid #28a745;
        border-radius: 0 8px 8px 0;
        margin: 2px 0 6px 0.75rem;
        padding: 4px 0;
    }
    .aptx-navbar .dropdown-item {
        padding: 8px 16px;
        font-size: 13px;
        transition: padding-left 0.12s, background 0.12s;
    }
    .aptx-navbar .dropdown-item:hover {
        background: rgba(40,167,69,0.08);
        padding-left: 22px;
        color: #28a745;
    }

    .aptx-topbar .d-flex { flex-wrap: wrap; justify-content: center; }
}

/* Dark mode mobile */
[data-bs-theme="dark"] .aptx-navbar .dropdown-menu,
body.dark-mode .aptx-navbar .dropdown-menu {
    background: #232830;
}
[data-bs-theme="dark"] .aptx-navbar .nav-item,
body.dark-mode .aptx-navbar .nav-item {
    border-bottom-color: rgba(255,255,255,0.05);
}

@media (max-width: 768px) {
    .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .container { padding-left: 12px; padding-right: 12px; }
    .footer .usefull-link .row > div { margin-bottom: 1rem; }
}

@media (max-width: 576px) {
    .modal-dialog { margin: 0.5rem; }
    .modal-body iframe { height: 200px; }
}


/* === Mobile: Episodios year collapse === */
.aptx-year-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    background: rgba(40,167,69,0.06);
    border: none;
    border-top: 1px solid rgba(40,167,69,0.15);
    border-bottom: 1px solid rgba(40,167,69,0.15);
    padding: 9px 16px;
    color: #1a7a35;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    gap: 8px;
    margin: 2px 0;
}
.aptx-year-toggle:hover { color: #28a745; background: rgba(40,167,69,0.12); }
.aptx-year-toggle .bi { color: #28a745; font-size: 1rem; }

.aptx-chevron { transition: transform 0.25s ease; }

.aptx-year-collapse { padding: 4px 0; }

.aptx-year-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #28a745;
    padding: 10px 16px 3px;
}
.aptx-year-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(40,167,69,0.25);
}
.aptx-year-label:first-child { padding-top: 6px; }

/* Desktop: ensure nav items are centered via mx-auto on the ul */
@media (min-width: 992px) {
    .aptx-navbar .navbar-collapse { flex-grow: 1; }
}

/* Dark mode — year collapse */
[data-bs-theme="dark"] .aptx-year-toggle,
body.dark-mode .aptx-year-toggle {
    color: #5cdb8a;
    background: rgba(40,167,69,0.08);
    border-color: rgba(40,167,69,0.2);
}
[data-bs-theme="dark"] .aptx-year-toggle:hover,
body.dark-mode .aptx-year-toggle:hover { color: #28a745; background: rgba(40,167,69,0.15); }
[data-bs-theme="dark"] .aptx-year-label,
body.dark-mode .aptx-year-label { color: #5cdb8a; }
[data-bs-theme="dark"] .aptx-year-label::after,
body.dark-mode .aptx-year-label::after { background: rgba(92,219,138,0.2); }


/* === Cookie Consent Banner === */
.aptx-consent {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #1a1d21;
    border-top: 3px solid #28a745;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.35);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}
.aptx-consent.aptx-consent-visible { transform: translateY(0); }
.aptx-consent-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 14px 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}
.aptx-consent-text {
    flex: 1;
    font-size: 0.82rem;
    color: #adb5bd;
    line-height: 1.5;
    min-width: 220px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.aptx-consent-text .bi { color: #28a745; font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.aptx-consent-text a { color: #28a745; text-decoration: none; }
.aptx-consent-text a:hover { text-decoration: underline; }
.aptx-consent-actions { display: flex; gap: 8px; flex-shrink: 0; }
.aptx-consent-btn {
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.aptx-consent-reject {
    background: transparent;
    border: 1px solid #5a6370;
    color: #adb5bd;
}
.aptx-consent-reject:hover { border-color: #fff; color: #fff; }
.aptx-consent-accept { background: #28a745; border: 1px solid #28a745; color: #fff; }
.aptx-consent-accept:hover { background: #218838; border-color: #218838; }

@media (max-width: 576px) {
    .aptx-consent-inner { flex-direction: column; gap: 0.75rem; }
    .aptx-consent-actions { width: 100%; }
    .aptx-consent-btn { flex: 1; text-align: center; }
}


/* === Movie navigation (prev/next buttons) === */
#container > .row:first-child,
.container > br + .row {
    display: flex !important;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
}
#container > .row:first-child > .col-md-2,
.container > br + .row > .col-md-2 {
    flex: 0 0 auto;
    width: auto;
}
#container > .row:first-child > .col-md-8,
.container > br + .row > .col-md-8 {
    flex: 1;
    text-align: center;
}
#container > .row:first-child h5.btn,
.container > br + .row h5.btn {
    display: inline-block;
    margin: 0;
    font-size: 0.85rem;
    white-space: nowrap;
}


/* === Especiales & Películas pages === */
[data-bs-theme="dark"] .card.bg-secondary { background-color: #2d3238 !important; }
[data-bs-theme="dark"] .card.bg-secondary .card-header { background-color: #343a40 !important; }
[data-bs-theme="dark"] .card.bg-light { background-color: #2d3238 !important; color: #e0e0e0 !important; }
[data-bs-theme="dark"] .card.bg-light .card-header { color: #fff !important; }
[data-bs-theme="dark"] #container h3, [data-bs-theme="dark"] #container h4 { color: #fff; }
[data-bs-theme="dark"] #container .text-muted { color: #adb5bd !important; }
[data-bs-theme="dark"] .card-footer { background-color: #1e2228 !important; }


/* === Especiales pages unified style === */
#container > .row:first-of-type h3 {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#container > .row:first-of-type h3 small {
    display: block;
    font-size: 0.85rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 4px;
}

#container .card.bg-secondary {
    background: #fff !important;
    color: #333 !important;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#container .card.bg-secondary .card-header {
    background: #f8f9fa !important;
    color: #2c3e50 !important;
    border-bottom: 2px solid #28a745;
    border-radius: 12px 12px 0 0 !important;
    font-size: 1.1rem !important;
    font-weight: 600;
}

#container .card.bg-secondary .card-body {
    color: #555;
}

#container .card.bg-success {
    border-radius: 12px;
}

#container .card.bg-light {
    background: #fff !important;
    border: 1px solid #e8e8e8;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

#container .card.bg-light .card-header {
    background: #f8f9fa !important;
    color: #2c3e50 !important;
    border-bottom: 2px solid #28a745;
    border-radius: 12px 12px 0 0 !important;
    font-size: 1.1rem !important;
    font-weight: 600;
}

#container .card-footer {
    background: #f8f9fa !important;
    border-radius: 0 0 12px 12px !important;
}

/* Dark mode for especiales */
[data-bs-theme="dark"] #container .card.bg-secondary,
[data-bs-theme="dark"] #container .card.bg-light {
    background: #1e2228 !important;
    border-color: #2d3238 !important;
    color: #e0e0e0 !important;
}

[data-bs-theme="dark"] #container .card.bg-secondary .card-header,
[data-bs-theme="dark"] #container .card.bg-light .card-header {
    background: #252a30 !important;
    color: #fff !important;
}

[data-bs-theme="dark"] #container .card.bg-secondary .card-body {
    color: #ccc !important;
}

[data-bs-theme="dark"] #container .card-footer {
    background: #1a1d21 !important;
}

[data-bs-theme="dark"] #container h3 { color: #fff; }
[data-bs-theme="dark"] #container h3 small { color: #adb5bd !important; }

/* Download icons in especiales */
#container .card-body a img[height] {
    transition: transform 0.2s;
}
#container .card-body a:hover img[height] {
    transform: scale(1.1);
}

/* Responsive for especiales */
@media (max-width: 768px) {
    #container .card-body a img[height] {
        height: 60px !important;
        margin: 4px;
    }
    #container > .row > .col-md-4 {
        margin-bottom: 1rem;
    }
    #container > .row > .col-md-4 img.img-fluid {
        max-height: 250px;
        width: auto;
        display: block;
        margin: 0 auto 1rem;
    }
    #container br { display: none; }
    #container > br { display: none; }
}
