/* ============================================================
   Movi Player — Advanced Settings Modal
   Centered popup with left sidebar nav + right content panel
   File: styles/settings.css
   ============================================================ */

:root {
    --sm-bg: #1e1f24;
    --sm-sidebar: #17181c;
    --sm-surface: rgba(255, 255, 255, 0.04);
    --sm-surface-hover: rgba(255, 255, 255, 0.07);
    --sm-border: rgba(255, 255, 255, 0.08);
    --sm-text: #e5e7eb;
    --sm-text-muted: #9ca3af;
    --sm-accent: #3b82f6;
    --sm-accent-hover: #60a5fa;
    --sm-danger: #ef4444;
    --sm-radius: 14px;
    --sm-font: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Remove mobile blue tap highlight & focus outline on Settings elements */
.sm-modal *,
.top-settings-btn {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0) !important;
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none;
    user-select: none;
}

.sm-modal *:focus,
.sm-modal *:focus-visible,
.sm-modal *:active {
    outline: none !important;
    -webkit-focus-ring-color: transparent !important;
}

/* ============================================================
   TOP-RIGHT GEAR ICON (trigger button)
   ============================================================ */
.top-settings-btn {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 500;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.top-settings-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.top-settings-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    transition: transform 0.35s ease;
}

.top-settings-btn:hover svg {
    transform: rotate(45deg);
}

/* ============================================================
   BACKDROP OVERLAY
   ============================================================ */
#settings-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#settings-modal-backdrop.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================
   MODAL CONTAINER
   ============================================================ */
#settings-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    z-index: 9999;
    width: 680px;
    max-width: 92vw;
    height: 480px;
    max-height: 80vh;
    background: var(--sm-bg);
    border-radius: var(--sm-radius);
    border: 1px solid var(--sm-border);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
    display: flex;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    font-family: var(--sm-font);
}

#settings-modal.open {
    opacity: 1;
    pointer-events: auto;
    transform: translate(-50%, -50%) scale(1);
}

/* ============================================================
   LEFT SIDEBAR
   ============================================================ */
.sm-sidebar {
    width: 190px;
    min-width: 190px;
    background: var(--sm-sidebar);
    border-right: 1px solid var(--sm-border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.sm-sidebar-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    padding: 0 20px 16px;
    letter-spacing: -0.01em;
}

.sm-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 8px;
}

.sm-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    border: none;
    background: none;
    color: var(--sm-text-muted);
    font-size: 0.84rem;
    font-weight: 500;
    font-family: var(--sm-font);
    cursor: pointer;
    transition: all 0.15s ease;
    text-align: left;
    width: 100%;
}

.sm-nav-item:hover {
    background: var(--sm-surface-hover);
    color: var(--sm-text);
}

.sm-nav-item.active {
    background: rgba(59, 130, 246, 0.12);
    color: #fff;
}

.sm-nav-item svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    flex-shrink: 0;
    opacity: 0.7;
}

.sm-nav-item.active svg {
    opacity: 1;
    color: var(--sm-accent);
}

/* ============================================================
   RIGHT CONTENT PANEL
   ============================================================ */
.sm-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sm-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px 14px;
    border-bottom: 1px solid var(--sm-border);
    flex-shrink: 0;
}

.sm-content-title {
    font-size: 0.95rem;
    font-weight: 650;
    color: #fff;
}

.sm-close-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: none;
    border: 1px solid transparent;
    color: var(--sm-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0;
}

.sm-close-btn:hover {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
    color: var(--sm-danger);
}

.sm-close-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Content body (scrollable) */
.sm-content-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 22px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

/* Each section/page */
.sm-page {
    display: none;
    flex-direction: column;
    gap: 6px;
    animation: smFadeIn 0.18s ease-out;
}

.sm-page.active {
    display: flex;
}

@keyframes smFadeIn {
    from { opacity: 0; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   SETTING ROWS
   ============================================================ */
.sm-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    gap: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}

.sm-setting-row:last-child {
    border-bottom: none;
}

.sm-setting-info {
    flex: 1;
    min-width: 0;
}

.sm-setting-label {
    font-size: 0.875rem;
    font-weight: 530;
    color: var(--sm-text);
}

.sm-setting-desc {
    font-size: 0.76rem;
    color: var(--sm-text-muted);
    margin-top: 2px;
    line-height: 1.35;
}

/* Section Dividers */
.sm-section-title {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--sm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 14px 0 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sm-section-title:first-child {
    padding-top: 0;
}

/* ============================================================
   TOGGLE SWITCHES
   ============================================================ */
.sm-toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 42px;
    height: 24px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    outline: none;
    transition: background 0.25s ease;
    flex-shrink: 0;
}

.sm-toggle::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.sm-toggle:checked {
    background: var(--sm-accent);
}

.sm-toggle:checked::after {
    transform: translateX(18px);
}

/* ============================================================
   RANGE SLIDERS
   ============================================================ */
.sm-range {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
    max-width: 160px;
}

.sm-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--sm-accent);
    cursor: pointer;
    box-shadow: 0 0 6px rgba(59,130,246,0.3);
    transition: transform 0.12s ease;
}

.sm-range::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

/* Value badges */
.sm-value {
    font-size: 0.78rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    color: var(--sm-accent);
    min-width: 42px;
    text-align: right;
    flex-shrink: 0;
}

/* ============================================================
   SELECT DROPDOWNS
   ============================================================ */
.sm-select {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--sm-border);
    color: var(--sm-text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: var(--sm-font);
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
}

.sm-select:hover,
.sm-select:focus {
    border-color: var(--sm-accent);
}

.sm-select option {
    background: #1e1f24;
    color: #fff;
}

/* ============================================================
   COLOR PICKER
   ============================================================ */
.sm-color {
    appearance: none;
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 0;
    background: transparent;
}

.sm-color::-webkit-color-swatch-wrapper { padding: 0; }
.sm-color::-webkit-color-swatch {
    border: 1px solid var(--sm-border);
    border-radius: 6px;
}

/* ============================================================
   EQ BAND ROWS
   ============================================================ */
.sm-eq-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 0;
}

.sm-eq-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--sm-text);
    min-width: 52px;
}

.sm-eq-sublabel {
    font-size: 0.68rem;
    color: var(--sm-text-muted);
    font-weight: 400;
}

.sm-eq-range {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.sm-eq-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--sm-accent);
    cursor: pointer;
    box-shadow: 0 0 5px rgba(59,130,246,0.25);
}

.sm-eq-badge {
    font-size: 0.72rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    color: var(--sm-accent);
    min-width: 40px;
    text-align: right;
}

/* ============================================================
   SUBTITLE PREVIEW BOX
   ============================================================ */
.sm-sub-preview {
    width: 100%;
    height: 72px;
    background: #000;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--sm-border);
    margin-bottom: 4px;
    background-image:
        linear-gradient(45deg, #141414 25%, transparent 25%),
        linear-gradient(-45deg, #141414 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #141414 75%),
        linear-gradient(-45deg, transparent 75%, #141414 75%);
    background-size: 14px 14px;
    background-position: 0 0, 0 7px, 7px -7px, -7px 0px;
}

.sm-sub-preview-text {
    font-family: var(--sm-font);
    transition: all 0.15s ease;
    text-align: center;
    padding: 4px 10px;
    border-radius: 3px;
}

/* ============================================================
   GPU INFO CARD
   ============================================================ */
.sm-gpu-card {
    margin-top: 4px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--sm-border);
    border-radius: 8px;
}

.sm-gpu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.sm-gpu-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sm-text-muted);
}

.sm-gpu-badge {
    font-size: 0.68rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    white-space: nowrap;
}

.sm-gpu-badge.active {
    color: #34d399;
    background: rgba(52,211,153,0.1);
    border: 1px solid rgba(52,211,153,0.2);
}

.sm-gpu-badge.disabled {
    color: #6b7280;
    background: rgba(107,114,128,0.08);
    border: 1px solid rgba(107,114,128,0.2);
}

.sm-gpu-badge.software {
    color: #f59e0b;
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
}

.sm-gpu-renderer {
    font-size: 0.74rem;
    color: #d1d5db;
    font-family: 'SF Mono', 'Cascadia Code', monospace;
    line-height: 1.35;
    word-break: break-word;
}

/* ============================================================
   HISTORY LIST
   ============================================================ */
.sm-history-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
    background: var(--sm-surface);
    border: 1px solid var(--sm-border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    margin-bottom: 6px;
}

.sm-history-item:hover {
    background: var(--sm-surface-hover);
}

.sm-history-title {
    font-size: 0.82rem;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 22px;
}

.sm-history-meta {
    font-size: 0.72rem;
    color: var(--sm-text-muted);
    display: flex;
    justify-content: space-between;
}

.sm-history-bar-bg {
    height: 3px;
    background: rgba(255,255,255,0.08);
    border-radius: 2px;
    overflow: hidden;
}

.sm-history-bar-fill {
    height: 100%;
    background: var(--sm-accent);
    border-radius: 2px;
}

.sm-history-delete {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 22px;
    height: 22px;
    background: none;
    border: none;
    color: #f87171;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sm-history-item:hover .sm-history-delete {
    opacity: 1;
}

.sm-empty-history {
    text-align: center;
    color: var(--sm-text-muted);
    font-size: 0.82rem;
    padding: 28px 0;
}

/* ============================================================
   SUBTITLE GLOBAL CSS OVERRIDES
   ============================================================ */
::cue, ::-webkit-media-text-track-display {
    font-size: var(--sub-size, 100%) !important;
    color: var(--sub-color, #ffffff) !important;
    background-color: var(--sub-bg, rgba(0, 0, 0, 0.75)) !important;
    text-shadow: var(--sub-shadow, 0px 0px 4px #000) !important;
    transform: translateY(var(--sub-pos-y, 0%)) translateX(var(--sub-pos-x, 0%)) !important;
}

/* ============================================================
   RESPONSIVE — small screens collapse sidebar
   ============================================================ */
@media (max-width: 600px) {
    #settings-modal {
        width: 96vw;
        height: 85vh;
        flex-direction: column;
    }

    .sm-sidebar {
        width: 100%;
        min-width: unset;
        flex-direction: row;
        border-right: none;
        border-bottom: 1px solid var(--sm-border);
        padding: 10px 6px 6px;
        gap: 0;
        overflow-x: auto;
    }

    .sm-sidebar-title {
        display: none;
    }

    .sm-nav {
        flex-direction: row;
        gap: 2px;
        padding: 0;
        width: 100%;
    }

    .sm-nav-item {
        flex: 1;
        justify-content: center;
        padding: 8px 6px;
        font-size: 0.72rem;
        gap: 4px;
    }

    .sm-nav-item svg {
        width: 14px;
        height: 14px;
    }
}
