/**
 * Premium Settings Page Styles
 * Matches compare.html dark theme
 */

/* Hidden utility class */
.hidden {
    display: none !important;
}

/* ==================== Settings Content Container ==================== */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    padding-right: calc(1.5rem + 50px); /* Space for sidebar icon strip */
    background: #0f172a; /* Match panel background */
}

/* ==================== Loading State ==================== */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem;
}

.loading-spinner {
    text-align: center;
    color: #94a3b8;
}

.loading-spinner p {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #334155;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==================== Settings Sections ==================== */
.settings-section {
    max-width: 800px;
    margin: 0 auto 1.5rem;
    background: #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #334155;
}

.section-header {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #334155;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.5rem;
    color: #f1f5f9;
}

.section-header h2 i {
    color: #fbbf24;
    font-size: 1.25rem;
}

.section-header p {
    color: #94a3b8;
    font-size: 0.85rem;
    margin: 0;
}

/* ==================== Assistant Grid ==================== */
.assistant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.assistant-card {
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 10px;
    padding: 1.25rem 1rem;
    text-align: center;
    transition: all 0.2s ease;
}

.assistant-card:hover {
    border-color: #475569;
}

.assistant-card.active {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
}

.assistant-card.coming-soon {
    opacity: 0.5;
}

.assistant-icon {
    font-size: 2rem;
    color: #60a5fa;
    margin-bottom: 0.75rem;
}

.assistant-card h3 {
    font-size: 0.9rem;
    margin: 0 0 1rem;
    font-weight: 600;
    color: #f1f5f9;
}

/* ==================== Toggle Switch (Fixed) ==================== */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    border-radius: 24px;
    transition: background-color 0.3s ease;
}

/* Override compare.css ::after - only use ::before for the circle */
.toggle-switch .toggle-slider::after {
    content: none !important;
}

.toggle-switch .toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: #f1f5f9;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #3b82f6;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(20px);
}

.coming-soon-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    padding: 0.25rem 0.6rem;
    background: #334155;
    border-radius: 12px;
    color: #94a3b8;
}

/* ==================== Watermark Settings ==================== */
.watermark-settings {
    background: #0f172a;
    border-radius: 10px;
    padding: 1.25rem;
    border: 1px solid #334155;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label,
.style-selector label,
.watermark-preview-container label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #f1f5f9;
    margin-bottom: 0.5rem;
}

.text-input {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    font-size: 0.9rem;
    color: #f1f5f9;
    transition: border-color 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.text-input::placeholder {
    color: #64748b;
}

.style-selector {
    margin-bottom: 1.25rem;
}

.style-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
}

.style-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    padding: 0.75rem 0.5rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #f1f5f9;
}

.style-option:hover {
    border-color: #475569;
}

.style-option.selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
}

.style-preview {
    font-size: 1.25rem;
    font-weight: 600;
}

.style-name {
    font-size: 0.7rem;
    color: #94a3b8;
}

/* Watermark Styles */
.style-1, .watermark-text.style-1 {
    color: #60a5fa;
    text-shadow: 0 0 10px rgba(96, 165, 250, 0.5);
}

.style-2, .watermark-text.style-2 {
    color: #94a3b8;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.4);
}

.style-3, .watermark-text.style-3 {
    color: #4ade80;
    text-shadow: 0 0 8px rgba(74, 222, 128, 0.4);
}

.style-4, .watermark-text.style-4 {
    color: #f87171;
    text-shadow: 0 0 8px rgba(248, 113, 113, 0.4);
}

.watermark-preview-container {
    margin-top: 1rem;
}

.watermark-preview {
    background: #334155;
    border: 1px solid #475569;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.watermark-text {
    font-size: 1rem;
    padding: 0.5rem 1rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 6px;
}

/* ==================== UI Preferences ==================== */
.preference-groups {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.preference-groups.ui-prefs {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.preference-group {
    background: #0f172a;
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid #334155;
}

.preference-group > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: #f1f5f9;
    margin-bottom: 0.75rem;
}

.button-group {
    display: flex;
    gap: 0.5rem;
}

.size-button {
    flex: 1;
    padding: 0.6rem 0.75rem;
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.size-button:hover {
    border-color: #475569;
    color: #f1f5f9;
}

.size-button.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* ==================== Conversation Limits ==================== */
.conversation-limit-group {
    max-width: 100%;
}

.preference-description {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.slider-container {
    margin-bottom: 1rem;
}

.slider-value-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.current-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #fbbf24;
}

.value-range {
    font-size: 0.75rem;
    color: #64748b;
}

.conversation-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #334155;
    outline: none;
    -webkit-appearance: none;
    margin-bottom: 0.5rem;
}

.conversation-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fbbf24;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.conversation-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fbbf24;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 1rem;
}

.limit-info {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    background: rgba(51, 65, 85, 0.5);
    border: 1px solid #334155;
    margin-bottom: 1.5rem;
}

.info-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.info-badge.no-saving {
    color: #f87171;
}

.info-badge.limited {
    color: #fbbf24;
}

.info-badge i {
    font-size: 1rem;
}

/* Unsaved changes indicator */
.unsaved-indicator {
    color: #fbbf24;
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ==================== Clear All Chats Section ==================== */
.clear-chats-section {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
}

.clear-chats-section > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #f87171;
    margin-bottom: 0.5rem;
}

.clear-all-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.clear-all-button:hover:not(:disabled) {
    background: #b91c1c;
    transform: translateY(-1px);
}

.clear-all-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    display: inline-block;
}

/* ==================== Save Section ==================== */
.save-section {
    max-width: 800px;
    margin: 0 auto 2rem;
    text-align: center;
    padding: 1rem;
}

.save-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.save-button:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.save-button.has-changes {
    background: #f59e0b;
    animation: pulse 2s infinite;
}

.save-hint {
    font-size: 0.85rem;
    color: #fbbf24;
    margin-top: 0.75rem;
    margin-bottom: 0;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

/* ==================== Toast Notifications ==================== */
#toast-container {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
}

.toast-notification {
    padding: 0.875rem 1.5rem;
    background: #1e293b;
    color: #f1f5f9;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    border: 1px solid #334155;
    margin-bottom: 0.5rem;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

.toast-notification.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    border-color: rgba(34, 197, 94, 0.5);
}

.toast-error {
    border-color: rgba(239, 68, 68, 0.5);
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .settings-content {
        padding: 1rem;
        padding-right: calc(1rem + 50px);
    }

    .settings-section {
        padding: 1rem;
        border-radius: 10px;
    }

    .assistant-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .style-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .button-group {
        flex-wrap: wrap;
    }

    .size-button {
        min-width: 50px;
    }
}

@media (max-width: 480px) {
    .style-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .style-option {
        padding: 0.5rem;
    }
}

/* ==================== AI Models Grid ==================== */
.ai-models-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.ai-models-grid .assistant-card {
    position: relative;
}

.ai-models-grid .assistant-card h3 {
    margin-bottom: 0.25rem;
}

.model-badge-small {
    display: block;
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 500;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Model-specific colors */
.assistant-card[data-type="chatgpt"] .assistant-icon {
    color: #10a37f;
}
.assistant-card[data-type="chatgpt"].active {
    border-color: #10a37f;
    background: rgba(16, 163, 127, 0.1);
}

.assistant-card[data-type="claude"] .assistant-icon {
    color: #d97706;
}
.assistant-card[data-type="claude"].active {
    border-color: #d97706;
    background: rgba(217, 119, 6, 0.1);
}

.assistant-card[data-type="gemini"] .assistant-icon {
    color: #4285f4;
}
.assistant-card[data-type="gemini"].active {
    border-color: #4285f4;
    background: rgba(66, 133, 244, 0.1);
}

.assistant-card[data-type="grok"] .assistant-icon {
    color: #f87171;
}
.assistant-card[data-type="grok"].active {
    border-color: #f87171;
    background: rgba(248, 113, 113, 0.1);
}

.assistant-card[data-type="deepseek"] .assistant-icon {
    color: #06b6d4;
}
.assistant-card[data-type="deepseek"].active {
    border-color: #06b6d4;
    background: rgba(6, 182, 212, 0.1);
}

.assistant-card[data-type="mistral"] .assistant-icon {
    color: #a855f7;
}
.assistant-card[data-type="mistral"].active {
    border-color: #a855f7;
    background: rgba(168, 85, 247, 0.1);
}

/* Responsive - 2 columns on tablet, 2 on mobile */
@media (max-width: 768px) {
    .ai-models-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .ai-models-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }

    .ai-models-grid .assistant-card {
        padding: 1rem 0.75rem;
    }

    .ai-models-grid .assistant-icon {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }

    .ai-models-grid .assistant-card h3 {
        font-size: 0.8rem;
    }

    .model-badge-small {
        font-size: 0.6rem;
    }
}

/* ==================== Force Vertical Sidebar on Premium Settings ==================== */
/* Override compare.css mobile styles to keep sidebar vertical on right */
.right-sidebar {
    position: fixed;
    right: 0;
    top: 60px;
    bottom: 0;
    left: auto;
    height: auto;
    flex-direction: row;
    z-index: 100;
}

.sidebar-icon-strip {
    width: 50px;
    height: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 0;
    gap: 8px;
    border-left: 1px solid #334155;
    border-top: none;
}

.sidebar-icon-spacer {
    display: none;
}

.sidebar-panel {
    position: relative;
    bottom: auto;
    left: auto;
    right: auto;
    width: 280px;
    height: 100%;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid #334155;
    z-index: auto;
    display: flex;
    flex-direction: column;
    background: #0f172a;
}

.sidebar-panel.hidden {
    display: none;
}

.sidebar-panel-backdrop {
    display: none !important;
}

.panel-drag-handle {
    display: none;
}

/* Adjust settings content to not overlap with sidebar */
.settings-content {
    padding-right: calc(1.5rem + 50px);
}

@media (max-width: 480px) {
    .settings-content {
        padding-right: calc(1rem + 50px);
    }
}

/* ==================== Light Mode Support ==================== */
:root:not([data-theme="dark"]) .settings-content,
[data-theme="light"] .settings-content {
    background: #f8fafc;
}

:root:not([data-theme="dark"]) .settings-section,
[data-theme="light"] .settings-section {
    background: #ffffff;
    border-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .section-header,
[data-theme="light"] .section-header {
    border-bottom-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .section-header h2,
[data-theme="light"] .section-header h2 {
    color: #1e293b;
}

:root:not([data-theme="dark"]) .section-header p,
[data-theme="light"] .section-header p {
    color: #64748b;
}

:root:not([data-theme="dark"]) .assistant-card,
[data-theme="light"] .assistant-card {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .assistant-card:hover,
[data-theme="light"] .assistant-card:hover {
    border-color: #cbd5e1;
}

:root:not([data-theme="dark"]) .assistant-card h3,
[data-theme="light"] .assistant-card h3 {
    color: #1e293b;
}

:root:not([data-theme="dark"]) .model-badge-small,
[data-theme="light"] .model-badge-small {
    color: #64748b;
}

:root:not([data-theme="dark"]) .toggle-switch .toggle-slider,
[data-theme="light"] .toggle-switch .toggle-slider {
    background-color: #cbd5e1;
}

/* Light mode: checked toggle should be blue */
:root:not([data-theme="dark"]) .toggle-switch input:checked + .toggle-slider,
[data-theme="light"] .toggle-switch input:checked + .toggle-slider {
    background-color: #3b82f6;
}

:root:not([data-theme="dark"]) .watermark-settings,
[data-theme="light"] .watermark-settings {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .text-input,
[data-theme="light"] .text-input {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

:root:not([data-theme="dark"]) .text-input::placeholder,
[data-theme="light"] .text-input::placeholder {
    color: #94a3b8;
}

:root:not([data-theme="dark"]) .style-option,
[data-theme="light"] .style-option {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #1e293b;
}

:root:not([data-theme="dark"]) .style-option:hover,
[data-theme="light"] .style-option:hover {
    border-color: #cbd5e1;
}

:root:not([data-theme="dark"]) .style-name,
[data-theme="light"] .style-name {
    color: #64748b;
}

:root:not([data-theme="dark"]) .watermark-preview,
[data-theme="light"] .watermark-preview {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

:root:not([data-theme="dark"]) .watermark-text,
[data-theme="light"] .watermark-text {
    background: rgba(255, 255, 255, 0.8);
}

:root:not([data-theme="dark"]) .preference-group,
[data-theme="light"] .preference-group {
    background: #f8fafc;
    border-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .preference-group > label,
[data-theme="light"] .preference-group > label {
    color: #1e293b;
}

:root:not([data-theme="dark"]) .preference-description,
[data-theme="light"] .preference-description {
    color: #64748b;
}

:root:not([data-theme="dark"]) .size-button,
[data-theme="light"] .size-button {
    background: #ffffff;
    border-color: #e2e8f0;
    color: #64748b;
}

:root:not([data-theme="dark"]) .size-button:hover,
[data-theme="light"] .size-button:hover {
    border-color: #cbd5e1;
    color: #1e293b;
}

:root:not([data-theme="dark"]) .conversation-slider,
[data-theme="light"] .conversation-slider {
    background: #e2e8f0;
}

:root:not([data-theme="dark"]) .limit-info,
[data-theme="light"] .limit-info {
    background: rgba(241, 245, 249, 0.8);
    border-color: #e2e8f0;
}

:root:not([data-theme="dark"]) .clear-chats-section,
[data-theme="light"] .clear-chats-section {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

:root:not([data-theme="dark"]) .toast-notification,
[data-theme="light"] .toast-notification {
    background: #ffffff;
    color: #1e293b;
    border-color: #e2e8f0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

:root:not([data-theme="dark"]) .input-group label,
:root:not([data-theme="dark"]) .style-selector label,
:root:not([data-theme="dark"]) .watermark-preview-container label,
[data-theme="light"] .input-group label,
[data-theme="light"] .style-selector label,
[data-theme="light"] .watermark-preview-container label {
    color: #1e293b;
}

/* Keep sidebar always in dark mode */
.sidebar-panel {
    background: #0f172a !important;
    border-color: #334155 !important;
}

.sidebar-icon-strip {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.sidebar-icon {
    color: #94a3b8 !important;
}

.sidebar-icon i {
    color: inherit !important;
}

.sidebar-icon:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

.sidebar-icon.active {
    background: rgba(251, 191, 36, 0.2) !important;
    color: #fbbf24 !important;
}

/* Theme toggle icon visibility */
.sidebar-icon.theme-toggle {
    color: #94a3b8 !important;
}

.sidebar-icon.theme-toggle:hover {
    color: #fbbf24 !important;
}

.sidebar-icon.theme-toggle i {
    color: inherit !important;
    display: inline-block !important;
}

.panel-header {
    border-bottom-color: #334155 !important;
}

.panel-title {
    color: #f1f5f9 !important;
}

.panel-close {
    color: #94a3b8 !important;
}

.panel-close:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}

.nav-item {
    color: #cbd5e1 !important;
}

.nav-item:hover {
    background: rgba(251, 191, 36, 0.1) !important;
    color: #fbbf24 !important;
}

.sidebar-footer a {
    color: #94a3b8 !important;
}

.sidebar-footer a:hover {
    color: #f1f5f9 !important;
}

.account-info {
    background: #1e293b !important;
    border-color: #334155 !important;
}

.user-email {
    color: #f1f5f9 !important;
}

.account-link {
    color: #cbd5e1 !important;
}

.account-link:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #f1f5f9 !important;
}
