:root {
    --bg: #121212;
    --card: #1e1e1e;
    --text: #e0e0e0;
    --accent: #ff6b00;
    --overlay: rgba(0, 0, 0, 0.95);
}

body {
    font-family: -apple-system, system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding-bottom: 80px;
    -webkit-tap-highlight-color: transparent;
}

* {
    box-sizing: border-box;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

.hidden {
    display: none !important;
}

.loader {
    border: 3px solid #333;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Auth Forms */
.center-box {
    max-width: 360px;
    margin: 60px auto;
    background: var(--card);
    padding: 30px;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

input {
    width: 100%;
    padding: 14px;
    margin: 8px 0;
    background: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 8px;
    font-size: 16px;
    outline: none;
    transition: 0.2s;
}

input:focus {
    border-color: var(--accent);
    background: #333;
}

button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 14px 20px;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    width: 100%;
    margin-top: 10px;
    transition: 0.2s;
}

button:active {
    transform: scale(0.98);
}

/* New: Disabled State */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.5);
}

button.secondary {
    background: #333;
    color: #ccc;
}

button.danger {
    background: #d32f2f;
}

button.sm {
    width: auto;
    padding: 8px 16px;
    font-size: 13px;
}

/* Navigation */
.tabs {
    display: flex;
    justify-content: space-around;
    gap: 5px;
    background: rgba(18, 18, 18, 0.95);
    backdrop-filter: blur(10px);
    padding: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #333;
    max-width: 1200px;
    margin: 0 auto;
}

.tab-btn {
    background: transparent;
    color: #888;
    border: none;
    font-size: 24px;
    padding: 12px 16px;
    border-radius: 12px;
    width: auto;
    margin: 0;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 80px;
    flex: 1;
    max-width: 200px;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
}

.tab-btn.active {
    color: var(--accent, #ff6b00);
    background: rgba(255, 107, 0, 0.1);
    transform: translateY(-1px);
}

.tab-icon {
    font-size: 20px;
    line-height: 1;
}

.tab-text {
    display: block;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
}

/* Адаптация для ПК */
@media (min-width: 768px) {
    .tabs {
        gap: 10px;
        padding: 15px 20px;
        justify-content: center;
    }

    .tab-btn {
        flex-direction: row;
        padding: 12px 24px;
        border-radius: 16px;
        gap: 8px;
        min-width: 120px;
        flex: 0 1 auto;
    }

    .tab-icon {
        font-size: 18px;
    }

    .tab-text {
        font-size: 14px;
        font-weight: 600;
    }
}

@media (min-width: 1024px) {
    .tab-btn {
        padding: 14px 28px;
        min-width: 140px;
    }

    .tab-text {
        font-size: 15px;
    }
}

/* Плавные переходы */
.tab-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Улучшенная доступность */
.tab-btn:focus-visible {
    outline: 2px solid var(--accent, #ff6b00);
    outline-offset: 2px;
}

/* Content */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.card {
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.card:active {
    transform: scale(0.97);
}

.card img {
    width: 100%;
    height: 310px;
    object-fit: cover;
}

.card-body {
    padding: 12px;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}

.badge-film {
    background: #2196f3;
}

.badge-tv {
    background: #9c27b0;
}

.date-alert {
    color: #ffeb3b;
    font-size: 0.8rem;
    font-weight: 500;
    display: block;
    margin-top: 4px;
}

/* Priority Blocks */
.priority-block {
    margin-bottom: 30px;
    border-bottom: 1px solid #333;
    padding-bottom: 20px;
}

.priority-header {
    color: var(--accent);
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-state h3 {
    color: #888;
    margin-bottom: 10px;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
    opacity: 0.5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--overlay);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: #1e1e1e;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    border-radius: 20px 20px 0 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

@media(min-width: 600px) {
    .modal-overlay {
        align-items: center;
    }

    .modal {
        border-radius: 16px;
        margin: 20px;
        height: auto;
        max-height: 85vh;
        align-self: center;
        animation: zoomIn 0.2s;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    border: none;
    color: white;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
}

.modal-cover {
    width: 100%;
    height: 300px;
    object-fit: cover;
    object-position: top;
    mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 50%, transparent 100%);
}

.modal-content-box {
    padding: 20px;
    margin-top: -60px;
    position: relative;
    z-index: 2;
}

.modal-meta {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* Added for multi-line meta support */
}

.age-badge {
    border: 1px solid #888;
    color: #ccc;
    padding: 1px 5px;
    font-size: 0.8rem;
    border-radius: 3px;
    margin-right: 10px;
    display: inline-block;
    line-height: normal;
}

.modal-btns {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    align-items: stretch;
}

.modal-btns a,
.modal-btns button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    color: white;
    margin-top: 0;
    height: 44px;
}

.btn-play {
    background: #4caf50;
}

.btn-sub {
    background: #333;
}

.btn-sub.active {
    background: #d32f2f;
}

.btn-kp {
    background: #ff6b00;
    max-width: 60px;
    font-size: 0.8rem;
}

.modal-desc {
    line-height: 1.5;
    color: #ccc;
    font-size: 0.95rem;
    margin-top: 20px;
}

.season-list {
    max-height: 200px;
    overflow-y: auto;
    background: #252525;
    border-radius: 8px;
    padding: 10px;
}

.episode-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #333;
    font-size: 0.9rem;
}

.episode-row.future {
    color: var(--accent);
    font-weight: bold;
}

.episode-row.past {
    color: #666;
}

/* Similars */
.similars-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.sim-card {
    min-width: 100px;
    max-width: 100px;
    cursor: pointer;
}

.sim-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
    border-radius: 8px;
}

.sim-title {
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 5px;
    color: #ccc;
}

.btn-refresh-cache {
    width: 100%;
    margin-top: 20px;
    background: #333;
    color: #666;
}

/* Chips for Quick Search */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    background: #333;
    color: #aaa;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
}

.chip:hover {
    background: #444;
    color: #fff;
}

/* Profile Styles */
.profile-section {
    background: #252525;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.profile-label {
    color: #888;
    font-size: 0.85rem;
    margin-bottom: 5px;
}

.status-ok {
    color: #4caf50;
}

.status-warn {
    color: #ff9800;
}

.status-err {
    color: #f44336;
}

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    font-size: 0.9rem;
    z-index: 2000;
    animation: fadeUp 0.3s;
    white-space: nowrap;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}
