/* Imagilire Settings Panel CSS */

/* Settings Backdrop */
.settings-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 1999;
}

body.settings-panel-open {
    overflow: hidden;
}

.settings-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100dvh;
    background-color: white;
    box-shadow: -2px 0 18px rgba(0, 0, 0, 0.18);
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    z-index: 2000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .settings-panel {
        width: 33vw;
        min-width: 360px;
        max-width: 480px;
        border-radius: 14px 0 0 14px;
    }
}

.settings-panel.active {
    transform: translateX(0);
}

/* Settings Header */
.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
    position: sticky;
    top: 0;
    z-index: 1;
}

/* Settings Content */
.settings-content {
    padding: 1.5rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
}

@media (max-width: 767px) {
    .settings-panel {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Settings Options */
.settings-option {
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 1;
}

.settings-option label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.settings-option select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
}

.settings-description {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.5rem;
}

/* Voice Selector Container */
.voice-selector-container {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.voice-selector-container .voice-select {
    flex: 1;
    min-width: 0;
    max-width: calc(100% - 48px);
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-family: inherit;
    background-color: white;
    font-size: 0.95rem;
}

.voice-selector-container .preview-voice-btn {
    flex-shrink: 0;
    width: 40px;
    height: auto;
    padding: 0.5rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.voice-selector-container .preview-voice-btn:hover:not(:disabled) {
    background-color: var(--secondary-color);
    transform: scale(1.05);
}

.voice-selector-container .preview-voice-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.voice-selector-container .preview-voice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-selector-container .preview-voice-btn.playing {
    background-color: #e74c3c;
    animation: pulse-preview 1s infinite;
}

@keyframes pulse-preview {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Voice Groups */
.voice-select optgroup {
    font-weight: bold;
    font-style: normal;
    padding-top: 0.25rem;
}

.voice-select option {
    font-weight: normal;
    padding: 0.25rem 0.5rem;
}

/* Speech Rate Control */
.speech-rate-control {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.speech-rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.speech-rate-label {
    font-weight: 500;
    font-size: 0.95rem;
}

.speech-rate-value {
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
    min-width: 45px;
    text-align: right;
}

.speech-rate-slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: linear-gradient(to right, #e0e0e0 0%, var(--primary-color) 50%, #e0e0e0 100%);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.speech-rate-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.speech-rate-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.speech-rate-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.speech-rate-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.speech-rate-marks {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #666;
    margin-top: 0.25rem;
    padding: 0 2px;
}

.speech-rate-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.speech-rate-mark-recommended {
    color: var(--primary-color);
    font-weight: 600;
}

/* Privacy Link */
a.iubenda-cs-preferences-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
    margin-top: 0.5rem;
}

a.iubenda-cs-preferences-link:hover {
    color: var(--secondary-color);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    cursor: pointer;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 28px;
    transition: background .4s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    height: 24px;
    width: 24px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform .4s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}

input:checked + .toggle-slider {
    background: var(--primary-color);
}

input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-switch input:focus-visible + .toggle-slider {
    outline: 3px solid rgba(54,177,179,.4);
    outline-offset: 2px;
}

/* Close Button */
.close-settings-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Settings Icon (FAB) */
.settings-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border: none;
    font-size: 1.2rem;
    transition: var(--transition);
    z-index: 100;
}

.settings-icon:hover {
    background-color: var(--accent-color);
}

/* Settings Footer */
.settings-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    text-align: center;
}

.help-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

.help-link i {
    margin-right: 5px;
}

.help-link:hover {
    color: var(--secondary-color);
}

.feedback-link {
    display: inline-flex;
    align-items: center;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
    margin-bottom: 10px;
}

.feedback-link i {
    margin-right: 5px;
}

.feedback-link:hover {
    color: var(--secondary-color);
}
