/*
 * Pipali Styles - Settings Page
 * Includes: settings layout, form fields, save button
 */

.settings-page {
    padding: 24px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.settings-page ::selection {
    background: var(--color-selection-bg);
    color: var(--color-selection-text);
}

.settings-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0;
}

/* Tabs */
.settings-tabs {
    display: flex;
    gap: 4px;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.settings-tab:hover {
    color: var(--color-text);
    background: var(--color-bg-elevated);
}

.settings-tab.active {
    color: var(--color-accent);
    border-color: var(--color-accent);
}

.settings-tab svg {
    flex-shrink: 0;
}

.settings-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.settings-error {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 12px;
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius-md);
    color: var(--color-error-text);
    font-size: 13px;
    margin-bottom: 24px;
}

.settings-error svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* Settings Section */
.settings-section {
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.settings-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.settings-section-header + .settings-form {
    margin-top: 24px;
}

.settings-section-header .settings-section-title {
    margin-bottom: 8px;
}

.settings-section-header .settings-section-description {
    margin-bottom: 0;
}

.settings-section-header .toggle-switch {
    margin-top: 2px;
}

.settings-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 8px;
}

.settings-section-description {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin: 0 0 24px;
    line-height: 1.5;
}

/* Form */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-field label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
}

.settings-field-hint {
    font-size: 13px;
    color: var(--color-text-muted);
    margin: 0 0 4px;
    line-height: 1.4;
}

.settings-field input[type="text"] {
    padding: 10px 12px;
    font-size: 14px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.settings-field input[type="text"]:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.settings-field input[type="text"]::placeholder {
    color: var(--color-text-muted);
}

.settings-field textarea {
    padding: 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.6;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    resize: vertical;
    min-height: 150px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.settings-field textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.settings-field textarea::placeholder {
    color: var(--color-text-muted);
}

/* Actions */
.settings-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 8px;
}

.settings-save-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--color-accent);
    color: var(--color-bg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.settings-save-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.settings-save-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.settings-save-btn.saved {
    background: var(--color-success);
}

.settings-save-btn svg.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Multiple sections */
.settings-section + .settings-section {
    margin-top: 24px;
}

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section-title svg {
    color: var(--color-text-secondary);
}

/* Toggle Switch */
.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;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--color-border);
    transition: var(--transition);
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--color-bg);
    transition: var(--transition);
    border-radius: 50%;
}

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

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

/* Path List Editor */
.path-list-editor {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.path-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.path-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: 100px;
    font-size: 13px;
    max-width: 100%;
    min-width: 0;
}

.path-icon {
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.path-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-secondary);
    direction: rtl;
    text-align: left;
}

.path-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: var(--transition);
    opacity: 0.5;
}

.path-remove-btn:hover:not(:disabled) {
    color: var(--color-error-text);
    opacity: 1;
}

.path-remove-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.path-add-row {
    display: flex;
    gap: 8px;
}

.path-input {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-family: var(--font-mono);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.path-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.path-input::placeholder {
    color: var(--color-text-muted);
}

.path-add-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    background: var(--color-bg-elevated);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    cursor: pointer;
    transition: var(--transition);
}

.path-add-btn:hover:not(:disabled) {
    background: var(--color-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.path-add-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.path-browse-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--color-accent);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-bg);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.path-browse-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.path-browse-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive */
@media (max-width: 640px) {
    .settings-page {
        padding: 24px 16px;
    }

    .settings-header {
        flex-wrap: wrap;
    }

    .settings-section {
        padding: 16px;
    }

}
