/* ==========================================================================
   Settings Page Styles - E-Learn Platform
   ========================================================================== */

/* --- CSS Variables (Matching Dashboard Theme) --- */
:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #777777;
    --primary-blue: #0067f6;
    --primary-hover: #0056b3;
    --border-light: #e0e0e0;
    --danger-red: #dc3545;
    --danger-hover: #c82333;
    --success-green: #28a745;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Main Layout --- */
.settings-main {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: calc(100vh - 70px);
}

.settings-header {
    margin-bottom: 40px;
    text-align: center;
}

.settings-header h1 {
    font-size: 2.2rem;
    color: var(--text-main);
    margin-bottom: 10px;
    font-weight: 700;
}

.settings-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* --- Settings Container --- */
.settings-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- Setting Item (Button + Form Wrapper) --- */
.setting-item {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-normal);
}

.setting-item:hover {
    box-shadow: var(--shadow-md);
}

.setting-item.active {
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-blue);
}

.setting-item.danger-item.active {
    border-color: var(--danger-red);
}

/* --- Setting Button --- */
.setting-btn {
    width: 100%;
    padding: 24px 28px;
    background: var(--card-bg);
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    transition: background-color var(--transition-fast);
}

.setting-btn:hover {
    background-color: #fafafa;
}

.setting-btn:focus {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--primary-blue);
}

.btn-content {
    display: flex;
    align-items: center;
    gap: 20px;
}

.btn-icon {
    width: 50px;
    height: 50px;
    background: rgba(0, 103, 246, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--primary-blue);
    transition: var(--transition-normal);
}

.setting-item.active .btn-icon {
    background: var(--primary-blue);
    color: white;
    transform: scale(1.05);
}

.danger-item .btn-icon {
    background: rgba(220, 53, 69, 0.1);
    color: var(--danger-red);
}

.danger-item.active .btn-icon {
    background: var(--danger-red);
    color: white;
}

.btn-text h3 {
    font-size: 1.2rem;
    color: var(--text-main);
    margin-bottom: 4px;
    font-weight: 600;
}

.btn-text p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.btn-arrow {
    font-size: 1.2rem;
    color: var(--text-muted);
    transition: transform var(--transition-slow);
}

.setting-item.active .btn-arrow {
    transform: rotate(180deg);
}

/* --- Form Container (Sliding Panel) --- */
.setting-form-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition-normal);
    opacity: 0;
    background: #fafafa;
    border-top: 1px solid transparent;
}

.setting-item.active .setting-form-container {
    max-height: 500px;
    opacity: 1;
    border-top-color: var(--border-light);
}

/* --- Form Styles --- */
.setting-form {
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.form-group input[type="text"],
.form-group input[type="password"] {
    padding: 14px 16px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    font-size: 1rem;
    background: white;
    color: var(--text-main);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 4px rgba(0, 103, 246, 0.1);
}

.form-group input:disabled {
    background: #f0f0f0;
    color: var(--text-muted);
    cursor: not-allowed;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    font-size: 1.1rem;
    transition: color var(--transition-fast);
}

.toggle-password:hover {
    color: var(--primary-blue);
}

/* --- Checkbox Styling --- */
.checkbox-group {
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-main);
    line-height: 1.5;
}

.checkbox-label input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 22px;
    height: 22px;
    min-width: 22px;
    border: 2px solid var(--border-light);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    margin-top: 2px;
}

.checkbox-label input:checked + .checkmark {
    background: var(--danger-red);
    border-color: var(--danger-red);
}

.checkbox-label input:checked + .checkmark::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: white;
    font-size: 0.8rem;
}

.label-text {
    user-select: none;
}

/* --- Danger Warning Box --- */
.danger-warning {
    background: rgba(220, 53, 69, 0.08);
    border: 1px solid rgba(220, 53, 69, 0.2);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--danger-red);
    font-size: 0.95rem;
    margin-bottom: 10px;
}

.danger-warning i {
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* --- Form Actions --- */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.form-actions button {
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-cancel {
    background: transparent;
    color: var(--text-muted);
    border: 2px solid var(--border-light) !important;
}

.btn-cancel:hover {
    border-color: var(--text-main) !important;
    color: var(--text-main);
    background: #f0f0f0;
}

.btn-save {
    background: var(--primary-blue);
    color: white;
    flex: 1;
    justify-content: center;
}

.btn-save:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 103, 246, 0.3);
}

.btn-delete {
    background: var(--danger-red);
    color: white;
    flex: 1;
    justify-content: center;
}

.btn-delete:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    top: 90px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    border-left: 4px solid var(--success-green);
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    transform: translateX(420px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.error {
    border-left-color: var(--danger-red);
}

.toast.error i {
    color: var(--danger-red);
}

.toast i {
    font-size: 1.3rem;
    color: var(--success-green);
}

.toast-message {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 500;
}

/* --- Loading Spinner --- */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

button.loading {
    opacity: 0.8;
    cursor: not-allowed;
    pointer-events: none;
}

/* --- Responsive Design --- */
@media (max-width: 640px) {
    .settings-main {
        padding: 20px 15px;
    }
    
    .settings-header h1 {
        font-size: 1.8rem;
    }
    
    .setting-btn {
        padding: 18px 20px;
    }
    
    .btn-content {
        gap: 15px;
    }
    
    .btn-icon {
        width: 42px;
        height: 42px;
        font-size: 1.2rem;
    }
    
    .btn-text h3 {
        font-size: 1.1rem;
    }
    
    .btn-text p {
        font-size: 0.85rem;
    }
    
    .setting-form {
        padding: 20px;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions button {
        width: 100%;
        justify-content: center;
    }
    
    #toast-container {
        left: 15px;
        right: 15px;
        top: auto;
        bottom: 20px;
    }
    
    .toast {
        min-width: auto;
        max-width: none;
        transform: translateY(100px);
    }
    
    .toast.show {
        transform: translateY(0);
    }
}

/* --- Focus Visible for Accessibility --- */
.setting-btn:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.danger-btn:focus-visible {
    outline-color: var(--danger-red);
}