/* ══════════════════════════════════════════════════════════════════════════
   SETTINGS FRAMEWORK - PREFERENCES MODAL WINDOW (TPL-SET-03)
   1:1 Reference from AX-Digital-Marketing Desktop Home Preferences Dialog
   Decoupled, modular, and white-label ready for external project injection.
   ══════════════════════════════════════════════════════════════════════════ */

:root {
    --pref-bg-primary: #1e1e2f;
    --pref-bg-secondary: #292942;
    --pref-bg-tertiary: #2c2c3e;
    --pref-bg-quaternary: #3a3a5c;
    
    --pref-accent-primary: #5865f2;
    --pref-accent-hover: #4752c4;
    --pref-accent-active: #3c45a5;
    
    --pref-text-primary: #ffffff;
    --pref-text-secondary: #b9bbbe;
    --pref-text-muted: #8e9297;
    
    --pref-border-primary: #3a3a5c;
    --pref-border-secondary: #555580;
    --pref-border-focus: #5865f2;
    
    --pref-success: #28ca42;
    --pref-warning: #faa61a;
    --pref-danger: #f04747;
    --pref-pink-upgrade: #ff69b4;
}

/* ── STUDIO DESKTOP WRAPPER (For Studio Wireframe View) ─────────────────── */
.pref-studio-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #12131f;
    background-image: 
        radial-gradient(circle at 50% 20%, rgba(88, 101, 242, 0.12) 0%, transparent 50%),
        linear-gradient(180deg, #10111a 0%, #171828 100%);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    color: var(--pref-text-primary);
}

.pref-studio-toolbar {
    height: 48px;
    background: rgba(22, 23, 38, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
    flex-shrink: 0;
}

.pref-studio-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 600;
}

.pref-studio-tag {
    font-size: 11px;
    font-family: monospace;
    color: #818cf8;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 700;
}

.pref-studio-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pref-studio-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #ffffff;
}

.pref-studio-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.25);
}

.pref-studio-btn-primary {
    background: var(--pref-accent-primary);
    border-color: var(--pref-accent-primary);
}

.pref-studio-btn-primary:hover {
    background: var(--pref-accent-hover);
    border-color: var(--pref-accent-hover);
}

/* ── MODAL OVERLAY & CONTAINER ───────────────────────────────────────────── */
.preferences-modal-overlay {
    position: absolute;
    inset: 48px 0 0 0;
    background-color: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.preferences-modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* ── PREFERENCES DIALOG WINDOW (1:1 AX DIGITAL MARKETING) ────────────────── */
.preferences-dialog {
    background-color: var(--pref-bg-secondary);
    border: 1px solid var(--pref-border-primary);
    border-radius: 8px;
    min-width: 900px;
    max-width: 1000px;
    width: 940px;
    min-height: 580px;
    max-height: 84vh;
    height: 640px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.preferences-modal-overlay.hidden .preferences-dialog {
    transform: scale(0.96) translateY(10px);
}

/* ── DIALOG HEADER ───────────────────────────────────────────────────────── */
.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--pref-border-primary);
    background: var(--pref-bg-secondary);
    user-select: none;
    flex-shrink: 0;
}

.dialog-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--pref-text-primary);
    letter-spacing: -0.01em;
}

.dialog-close {
    background: none;
    border: none;
    color: var(--pref-text-secondary);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.dialog-close:hover {
    background-color: var(--pref-bg-tertiary);
    color: var(--pref-text-primary);
}

/* ── DIALOG BODY (SIDEBAR + CONTENT) ─────────────────────────────────────── */
.dialog-body {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── PREFERENCES SIDEBAR ─────────────────────────────────────────────────── */
.preferences-sidebar {
    width: 205px;
    flex-shrink: 0;
    border-right: 1px solid var(--pref-border-primary);
    background: var(--pref-bg-secondary);
    padding: 16px 0;
    overflow-y: auto;
    overflow-x: hidden;
    user-select: none;
}

.preferences-sidebar::-webkit-scrollbar {
    width: 5px;
}
.preferences-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.preferences-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--pref-text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 13.5px;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.preferences-nav-item:hover {
    background: var(--pref-bg-tertiary);
    color: var(--pref-text-primary);
}

.preferences-nav-item.active {
    background: var(--pref-bg-tertiary);
    color: var(--pref-accent-primary);
    font-weight: 600;
    border-left: 3px solid var(--pref-accent-primary);
}

.preferences-nav-item .nav-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preferences-nav-item .nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upgrade-badge {
    background: var(--pref-pink-upgrade);
    color: #ffffff;
    border: none;
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
    margin-left: auto;
    cursor: pointer;
    text-transform: capitalize;
    letter-spacing: 0.3px;
    box-shadow: 0 2px 6px rgba(255, 105, 180, 0.35);
    transition: transform 0.15s ease;
}

.upgrade-badge:hover {
    transform: scale(1.05);
}

.preferences-sidebar-divider {
    margin: 18px 0;
    border-top: 1px solid var(--pref-border-primary);
}

/* ── PREFERENCES CONTENT AREA ────────────────────────────────────────────── */
.preferences-content {
    flex: 1;
    padding: 28px 32px;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--pref-bg-primary);
    min-height: 0;
    max-height: 100%;
}

.preferences-content::-webkit-scrollbar {
    width: 6px;
}
.preferences-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.12);
    border-radius: 3px;
}
.preferences-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

.preferences-panel {
    display: none;
    animation: prefFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.preferences-panel.active {
    display: block;
}

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

.pref-panel-title {
    color: var(--pref-text-primary);
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 26px 0;
    letter-spacing: -0.01em;
}

.pref-section-group {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.pref-field-label {
    color: var(--pref-text-primary);
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 10px;
    display: block;
}

/* ── BUTTONS & SEGMENTED CONTROLS ────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13.5px;
}

.btn-primary {
    background: var(--pref-accent-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--pref-accent-hover);
}

.btn-secondary {
    background: var(--pref-bg-tertiary);
    color: var(--pref-text-primary);
    border: 1px solid var(--pref-border-primary);
}

.btn-secondary:hover {
    background: var(--pref-bg-quaternary);
}

.theme-segmented-group {
    display: flex;
    gap: 8px;
}

.theme-btn {
    flex: 1;
    padding: 10px 14px;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: 6px;
    background: var(--pref-bg-secondary);
    color: var(--pref-text-secondary);
    border: 1px solid var(--pref-border-primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.theme-btn:hover {
    color: #ffffff;
    background: var(--pref-bg-tertiary);
}

.theme-btn.active {
    background: #373752;
    color: #ffffff;
    border-color: #555580;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* ── RANGE SLIDERS ───────────────────────────────────────────────────────── */
.pref-slider-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

input[type="range"].pref-range-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--pref-bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    margin: 6px 0;
}

input[type="range"].pref-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--pref-accent-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease;
}

input[type="range"].pref-range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"].pref-range-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--pref-accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.pref-slider-val {
    text-align: center;
    color: var(--pref-text-secondary);
    font-size: 12px;
    font-family: monospace;
}

.pref-field-hint {
    color: var(--pref-text-secondary);
    font-size: 11.5px;
    margin-top: 4px;
    line-height: 1.4;
}

/* ── TOGGLE SWITCHES ─────────────────────────────────────────────────────── */
.pref-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
}

.pref-toggle-label {
    color: var(--pref-text-primary);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--pref-bg-tertiary);
    border: 2px solid var(--pref-border-primary);
    transition: 0.25s ease;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: var(--pref-text-secondary);
    transition: 0.25s ease;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--pref-accent-primary);
    border-color: var(--pref-accent-primary);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
    background-color: #ffffff;
}

/* ── FORM INPUTS & SELECTS ───────────────────────────────────────────────── */
.pref-input, .pref-select {
    width: 100%;
    padding: 10px 12px;
    background: var(--pref-bg-secondary);
    border: 1px solid var(--pref-border-primary);
    border-radius: 6px;
    color: var(--pref-text-primary);
    font-size: 13.5px;
    outline: none;
    transition: border-color 0.2s ease;
}

.pref-input:focus, .pref-select:focus {
    border-color: var(--pref-border-focus);
}

/* ── COLOR SWATCHES & TILES ──────────────────────────────────────────────── */
.pref-swatch-box {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    border: 2px solid var(--pref-border-primary);
    transition: transform 0.15s ease, border-color 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pref-swatch-box:hover {
    transform: scale(1.06);
    border-color: var(--pref-accent-primary) !important;
}

.pref-swatch-box.active {
    border-color: var(--pref-accent-primary);
    box-shadow: 0 0 12px rgba(88, 101, 242, 0.4);
}

.pref-swatch-label {
    position: absolute;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

.pref-color-input-box {
    width: 100%;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--pref-border-primary);
    background: var(--pref-bg-primary);
    cursor: pointer;
    padding: 0 4px;
}

/* ── FOCUS LIST CARDS ────────────────────────────────────────────────────── */
.focus-category-card {
    border: 1px solid var(--pref-border-primary);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: var(--pref-bg-secondary);
}

.focus-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    background: var(--pref-bg-secondary);
    user-select: none;
}

.focus-category-header:hover {
    background: var(--pref-bg-tertiary);
}

.focus-category-sites {
    padding: 10px 16px;
    background: var(--pref-bg-primary);
    border-top: 1px solid var(--pref-border-primary);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
}

/* ── TOOL CHIPS GRID ─────────────────────────────────────────────────────── */
.chips-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.chip-pref-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border: 1px solid var(--pref-border-primary);
    border-radius: 8px;
    background: var(--pref-bg-secondary);
}

.chip-pref-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chip-pref-icon {
    font-size: 18px;
}

.chip-pref-name {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--pref-text-primary);
}

/* ── ACCOUNT SECTION STYLING ─────────────────────────────────────────────── */
.account-pro-card {
    background: var(--pref-bg-secondary);
    border: 1px solid var(--pref-border-primary);
    border-radius: 8px;
    padding: 24px;
}

.account-feature-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 13.5px;
    color: var(--pref-text-primary);
}

.account-check-icon {
    color: var(--pref-success);
    font-weight: 700;
    font-size: 15px;
}

/* ── CLOSED MODAL REOPEN BANNER ─────────────────────────────────────────── */
.modal-closed-banner {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: absolute;
    inset: 48px 0 0 0;
    background: rgba(16, 17, 26, 0.85);
    z-index: 50;
}

.modal-closed-banner.active {
    display: flex;
}
