/**
 * Settings Page Styles
 * Estilos específicos para la página de ajustes con diseño Bentō
 *
 * @package BravesChat
 * @version 1.2.1
 */

/* ==================== SETTINGS SIDEBAR ==================== */
.braves-settings-sidebar .braves-admin-nav__sublist {
    margin-top: var(--braves-space-xs);
    margin-left: var(--braves-space-xl);
    padding-left: var(--braves-space-md);
    border-left: 2px solid var(--braves-gray-200);
}

.braves-settings-sidebar .braves-admin-nav__subitem {
    list-style: none;
    margin: 0;
}

.braves-settings-sidebar .braves-admin-nav__sublink {
    display: block;
    padding: var(--braves-space-xs) var(--braves-space-md);
    color: var(--braves-gray-600);
    text-decoration: none;
    font-size: var(--braves-text-sm);
    border-radius: var(--braves-radius-sm);
    transition: all var(--braves-transition-fast);
}

.braves-settings-sidebar .braves-admin-nav__sublink:hover {
    color: var(--braves-primary);
    background: var(--braves-gray-50);
}

/* ==================== SETTINGS CONTENT ==================== */
.braves-settings-content {
    padding-bottom: var(--braves-space-2xl);
}

/* ==================== SETTINGS SECTIONS ==================== */
.braves-settings-section {
    animation: fade-in 0.3s ease-out;
}

.braves-settings-section:not(:first-child) {
    margin-top: var(--braves-space-2xl);
}

/* ==================== SETTINGS FORM ==================== */
.braves-settings-form {
    margin: var(--braves-space-xl) 0;
}

/* ==================== FIELD GROUPS ==================== */
.braves-settings-field {
    background: var(--braves-surface);
    border: 1px solid var(--braves-border-color);
    border-radius: var(--braves-radius-lg);
    padding: var(--braves-space-lg);
    transition: all var(--braves-transition-fast);
}

.braves-settings-field:hover {
    border-color: var(--braves-gray-300);
    box-shadow: var(--braves-shadow);
}

.braves-settings-field--full {
    grid-column: 1 / -1;
}

.braves-field-group {
    display: flex;
    flex-direction: column;
    gap: var(--braves-space-sm);
}

.braves-field-label {
    font-size: var(--braves-text-base);
    font-weight: var(--braves-font-semibold);
    color: var(--braves-text-primary);
    margin: 0;
}

.braves-field-description {
    font-size: var(--braves-text-sm);
    color: var(--braves-text-secondary);
    line-height: var(--braves-leading-relaxed);
    margin: 0;
}

/* ==================== INPUT FIELDS ==================== */
.braves-field-input,
.braves-field-textarea,
.braves-field-select {
    border: 1px solid var(--braves-border-color);
    border-radius: var(--braves-radius-md);
    padding: var(--braves-space-sm) var(--braves-space-md);
    font-size: var(--braves-text-base);
    font-family: var(--braves-font-sans);
    color: var(--braves-text-primary);
    background: var(--braves-surface-input);
    transition: all var(--braves-transition-fast);
    width: 100%;
}

.braves-field-input:focus,
.braves-field-textarea:focus,
.braves-field-select:focus {
    border-color: var(--braves-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--braves-primary-lighter);
}

.braves-field-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: var(--braves-font-sans);
}

.braves-field-select--multiple {
    min-height: 200px;
    padding: var(--braves-space-xs);
}

.braves-field-select--multiple option {
    padding: var(--braves-space-sm) var(--braves-space-md);
    border-radius: var(--braves-radius-sm);
    margin-bottom: 2px;
}

/* ==================== FIELD HIGHLIGHT ==================== */
.braves-field-highlight {
    animation: field-highlight 2s ease-out;
}

@keyframes field-highlight {
    0% {
        box-shadow: 0 0 0 4px var(--braves-primary-lighter);
        border-color: var(--braves-primary);
    }

    100% {
        box-shadow: none;
        border-color: var(--braves-gray-200);
    }
}

/* ==================== DARK MODE: SETTINGS FIELDS ==================== */
[data-braves-theme="dark"] .braves-settings-field {
    background: var(--braves-surface);
    border-color: rgba(255, 255, 255, 0.07);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

[data-braves-theme="dark"] .braves-settings-field:hover {
    border-color: rgba(255, 255, 255, 0.13);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 4px 12px rgba(0, 0, 0, 0.4);
}

[data-braves-theme="dark"] .braves-settings-form h2 {
    border-bottom-color: rgba(255, 255, 255, 0.07);
}

[data-braves-theme="dark"] .braves-settings-form .form-table tr {
    border-bottom-color: rgba(255, 255, 255, 0.05);
}

[data-braves-theme="dark"] .braves-settings-actions {
    background: var(--braves-surface);
    border-color: rgba(255, 255, 255, 0.07);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.04),
        0 -4px 20px rgba(0, 0, 0, 0.4);
}

[data-braves-theme="dark"] .braves-section--actions {
    background: var(--braves-surface);
    border-color: rgba(255, 255, 255, 0.07);
}

/* ==================== SETTINGS ACTIONS ==================== */
.braves-settings-actions {
    margin-top: var(--braves-space-2xl);
    padding: var(--braves-space-xl);
    background: var(--braves-surface-alt);
    border-radius: var(--braves-radius-lg);
    border: 1px solid var(--braves-border-color);
    position: sticky;
    bottom: var(--braves-space-md);
    z-index: 10;
    box-shadow: var(--braves-shadow-lg);
}

/* ==================== FORM SECTIONS ==================== */
.braves-settings-form h2 {
    font-size: var(--braves-text-xl);
    font-weight: var(--braves-font-semibold);
    color: var(--braves-text-primary);
    margin: var(--braves-space-2xl) 0 var(--braves-space-lg) 0;
    padding-bottom: var(--braves-space-md);
    border-bottom: 1px solid var(--braves-border-color);
}

.braves-settings-form h2:first-child {
    margin-top: 0;
}

/* Section descriptions */
.braves-settings-form h2+p {
    margin-top: calc(var(--braves-space-lg) * -1);
    margin-bottom: var(--braves-space-lg);
    color: var(--braves-gray-600);
    font-size: var(--braves-text-sm);
}

/* ==================== FORM TABLE OVERRIDE ==================== */
.braves-settings-form .form-table {
    margin: 0;
    border: none;
    background: transparent;
}

.braves-settings-form .form-table th {
    padding: var(--braves-space-lg) var(--braves-space-md) var(--braves-space-lg) 0;
    font-weight: var(--braves-font-semibold);
    color: var(--braves-text-primary);
    font-size: var(--braves-text-base);
    width: 250px;
    vertical-align: top;
}

.braves-settings-form .form-table td {
    padding: var(--braves-space-lg) 0;
}

.braves-settings-form .form-table tr {
    border-bottom: 1px solid var(--braves-border-color);
}

.braves-settings-form .form-table tr:last-child {
    border-bottom: none;
}

/* ==================== INPUT FIELDS ==================== */
.braves-settings-form input[type="text"],
.braves-settings-form input[type="url"],
.braves-settings-form input[type="email"],
.braves-settings-form input[type="password"],
.braves-settings-form input[type="time"],
.braves-settings-form textarea,
.braves-settings-form select {
    border: 1px solid var(--braves-border-color);
    border-radius: var(--braves-radius-md);
    padding: var(--braves-space-sm) var(--braves-space-md);
    font-size: var(--braves-text-base);
    font-family: var(--braves-font-sans);
    color: var(--braves-text-primary);
    background: var(--braves-surface-input);
    box-shadow: var(--braves-shadow-sm);
    transition: all var(--braves-transition-fast);
    max-width: 500px;
    width: 100%;
}

.braves-settings-form input[type="text"]:focus,
.braves-settings-form input[type="url"]:focus,
.braves-settings-form input[type="email"]:focus,
.braves-settings-form input[type="password"]:focus,
.braves-settings-form input[type="time"]:focus,
.braves-settings-form textarea:focus,
.braves-settings-form select:focus {
    border-color: var(--braves-primary);
    outline: none;
    box-shadow: 0 0 0 3px var(--braves-primary-lighter);
}

/* Clock icon on time inputs — dark mode */
[data-braves-theme="dark"] input[type="time"].braves-input {
    color-scheme: dark;
}

[data-braves-theme="dark"] input[type="time"].braves-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
}

/* Password fields */
.braves-settings-form input[type="password"] {
    font-family: var(--braves-font-mono);
    letter-spacing: 2px;
}

/* Select múltiple */
.braves-settings-form select[multiple] {
    padding: var(--braves-space-sm);
    min-height: 200px;
}

.braves-settings-form select[multiple] option {
    padding: var(--braves-space-sm) var(--braves-space-md);
    border-radius: var(--braves-radius-sm);
    margin-bottom: 2px;
}

/* ==================== CHECKBOXES ==================== */
.braves-settings-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: var(--braves-space-sm);
    cursor: pointer;
    accent-color: var(--braves-primary);
    vertical-align: middle;
}

.braves-settings-form input[type="checkbox"]+label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: var(--braves-space-sm);
}

/* Dark mode: checkboxes custom */
[data-braves-theme="dark"] .braves-settings-form input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.07);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    position: relative;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    vertical-align: middle;
}

[data-braves-theme="dark"] .braves-settings-form input[type="checkbox"]:hover {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.1);
}

[data-braves-theme="dark"] .braves-settings-form input[type="checkbox"]:checked {
    background: var(--braves-primary);
    border-color: var(--braves-primary);
}

[data-braves-theme="dark"] .braves-settings-form input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

[data-braves-theme="dark"] .braves-settings-form input[type="checkbox"]:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(1, 183, 175, 0.2);
}

/* ==================== DESCRIPTIONS ==================== */
.braves-settings-form .description {
    color: var(--braves-gray-600);
    font-size: var(--braves-text-sm);
    line-height: var(--braves-leading-relaxed);
    margin-top: var(--braves-space-sm);
    display: block;
}

.braves-settings-form .description strong {
    color: var(--braves-text-primary);
    font-weight: var(--braves-font-semibold);
}

/* ==================== SUBMIT BUTTON ==================== */
.braves-settings-form .braves-section--actions {
    margin-top: var(--braves-space-2xl);
    padding: var(--braves-space-xl);
    background: var(--braves-surface-alt);
    border-radius: var(--braves-radius-lg);
    border: 1px solid var(--braves-border-color);
}

.braves-settings-form #submit {
    background: var(--braves-primary);
    border-color: var(--braves-primary);
    color: var(--braves-text-on-primary);
    font-size: var(--braves-text-base);
    font-weight: var(--braves-font-semibold);
    padding: var(--braves-space-md) var(--braves-space-xl);
    border-radius: var(--braves-radius-md);
    cursor: pointer;
    transition: all var(--braves-transition-fast);
    box-shadow: var(--braves-shadow);
}

.braves-settings-form #submit:hover {
    background: var(--braves-primary-hover);
    border-color: var(--braves-primary-hover);
    box-shadow: var(--braves-shadow-md);
    transform: translateY(-1px);
}

.braves-settings-form #submit:active {
    transform: translateY(0);
    box-shadow: var(--braves-shadow-sm);
}

.braves-settings-form #submit:focus {
    outline: 2px solid var(--braves-primary);
    outline-offset: 2px;
}

/* ==================== RANGE SLIDER TOOLTIP ==================== */
.braves-range-container {
    position: relative;
    width: 100%;
    margin-bottom: 5px;
}

.braves-range-tooltip {
    position: absolute;
    top: -35px;
    /* Adjust based on height */
    left: 0;
    transform: translateX(-50%);
    background-color: var(--braves-text-primary);
    color: var(--braves-bg-page);
    padding: 4px 8px;
    border-radius: var(--braves-radius-sm);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 100;
}

.braves-range-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 5px;
    border-style: solid;
    border-color: var(--braves-text-primary) transparent transparent transparent;
}

.braves-range-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* ==================== RANGE INPUT ==================== */
.braves-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 4px;
    border-radius: var(--braves-radius-full);
    background: linear-gradient(to right, var(--braves-primary) 0%, var(--braves-gray-300) 0%);
    outline: none;
    cursor: pointer;
    vertical-align: middle;
}

.braves-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--braves-primary);
    cursor: pointer;
    box-shadow: var(--braves-shadow-sm);
    transition: transform var(--braves-transition-fast);
}

.braves-range::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    background: var(--braves-primary);
    cursor: pointer;
    box-shadow: var(--braves-shadow-sm);
    transition: transform var(--braves-transition-fast);
}

.braves-range::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.braves-range::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.braves-range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    margin-bottom: 35px;
    font-size: 11px;
    color: var(--braves-text-secondary);
}

.braves-range-unit {
    font-size: 13px;
    color: var(--braves-text-secondary);
}

.braves-field-help {
    margin-top: 15px;
    font-size: 13px;
    color: var(--braves-text-secondary);
}

/* ==================== RESPONSIVE ==================== */
@media screen and (max-width: 782px) {

    .braves-settings-form .form-table th,
    .braves-settings-form .form-table td {
        display: block;
        width: 100%;
        padding: var(--braves-space-sm) 0;
    }

    .braves-settings-form .form-table th {
        padding-bottom: var(--braves-space-xs);
    }

    .braves-settings-form input[type="text"],
    .braves-settings-form input[type="url"],
    .braves-settings-form input[type="email"],
    .braves-settings-form input[type="password"],
    .braves-settings-form input[type="time"],
    .braves-settings-form textarea,
    .braves-settings-form select {
        max-width: 100%;
    }
}