:root {
    --bg-color: #f2f2f7;
    /* iOS Settings Gray */
    --card-bg: #ffffff;
    --text-primary: #000000;
    --text-secondary: #8a8a8e;
    --divider-color: #c6c6c8;
    --accent-color: #007aff;
    --danger-color: #ff3b30;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);

    /* Dynamic Brand Variables */
    --brand-primary: #34c759;
    /* Default Emerald */
    --brand-primary-rgb: 52, 199, 89;

    --icon-blue: #007aff;
    --icon-green: #34c759;
    --icon-orange: #ff9500;
    --icon-red: #ff3b30;
    --icon-purple: #5856d6;
    --icon-teal: #30b0c7;
    --icon-gray: #8e8e93;
    --icon-yellow: #ffcc00;
}

/* Dark Mode Variables matching Profile page methodology */
html.dark-mode {
    --bg-color: #000000;
    --card-bg: #1c1c1e;
    --text-primary: #ffffff;
    --text-secondary: #98989e;
    --divider-color: #38383a;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    padding-bottom: 40px;
    transition: background-color 0.3s ease;
}

/* HEADER */
.settings-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(var(--card-bg-rgb), 0.8);
    /* Fallback */
    background: var(--card-bg);
    /* Use card bg for now, blur later if needed */
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 0 var(--divider-color);
}

/* Make header seamless with bg in iOS style? No, standard app header is better */
.settings-header {
    background: var(--bg-color);
    /* Match body for cleaner look or card for distinct? Let's go Card color */
    background: var(--card-bg);
}

.settings-header h1 {
    font-size: 17px;
    font-weight: 600;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.back-btn {
    background: none;
    border: none;
    color: var(--accent-color);
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
}

/* CONTAINER */
.settings-container {
    max-width: 800px;
    /* Tablet constraint */
    margin: 0 auto;
    padding: 20px;
}

.group-title {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--theme-accent);
    margin: 30px 0 12px 18px;
    font-weight: 700;
    letter-spacing: 1.5px;
    opacity: 0.8;
}

/* SETTINGS GROUP CARD */
.settings-group {
    background: var(--card-bg);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--divider-color);
}

html.dark-mode .settings-group {
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.3);
    background: #1c1c1e;
}


.setting-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    min-height: 58px;
    background: transparent;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.setting-item.clickable {
    cursor: pointer;
}

.setting-item.clickable:active {
    background-color: rgba(var(--brand-primary-rgb), 0.1);
}


/* ICONS */
.icon-box {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    color: white;
    font-size: 15px;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

.icon-box.blue {
    background: linear-gradient(135deg, #007aff, #0051ff);
}

.icon-box.green {
    background: linear-gradient(135deg, #34c759, #248a3d);
}

.icon-box.orange {
    background: linear-gradient(135deg, #ff9500, #ff5e00);
}

.icon-box.red {
    background: linear-gradient(135deg, #ff3b30, #d70015);
}

.icon-box.purple {
    background: linear-gradient(135deg, #af52de, #8944ab);
}

.icon-box.teal {
    background: linear-gradient(135deg, #30beee, #007aff);
}

.icon-box.gray {
    background: linear-gradient(135deg, #8e8e93, #636366);
}

.icon-box.yellow {
    background: linear-gradient(135deg, #ffcc00, #ff9500);
}

/* CONTENT */
.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.label {
    font-size: 16px;
    font-weight: 500;
}

.sub-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.Value {
    font-size: 16px;
    color: var(--text-secondary);
    margin-right: 10px;
}

.action-icon {
    font-size: 14px;
    color: #c7c7cc;
    /* Standard arrow color */
}

/* THEME SELECTOR */
.theme-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-top: 15px;
    padding: 10px;
    background: rgba(var(--brand-primary-rgb), 0.05);
    border-radius: 15px;
}

.theme-dot {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 3px solid transparent;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.theme-dot:hover {
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.theme-dot.active {
    transform: scale(1.1);
    border-color: white;
    box-shadow: 0 0 0 2px var(--brand-primary);
}

.theme-dot.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 14px;
    color: white;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}


/* DIVIDER */
.divider {
    height: 1px;
    background: var(--divider-color);
    margin-left: 60px;
    /* Indent past icon */
    opacity: 0.4;
}

/* TOGGLE SWITCH */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 30px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e9e9ea;
    transition: .3s;
    border-radius: 30px;
}

html.dark-mode .slider {
    background-color: #39393d;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

input:checked+.slider {
    background-color: var(--brand-primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* BUTTONS */
.logout-btn {
    width: 100%;
    padding: 16px;
    margin-top: 30px;
    background: var(--card-bg);
    border: none;
    border-radius: 12px;
    color: var(--danger-color);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.logout-btn:active {
    opacity: 0.7;
}

.version-info {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* MODAL STYLES */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Center on desktop */
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s;
}

.modal-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 400px;
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-card {
    transform: scale(0.9);
}

/* Mobile Bottom Sheet effect */
@media (max-width: 600px) {
    .modal-overlay {
        align-items: flex-end;
        /* Bottom sheet */
    }

    .modal-card {
        width: 100%;
        max-width: 100%;
        border-radius: 20px 20px 0 0;
        margin-bottom: 0;
    }
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--divider-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
}

.modal-body {
    padding: 20px;
}

/* Modal Inputs */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px;
    padding-right: 40px;
    /* Space for the eye icon */
    border-radius: 8px;
    border: 1px solid var(--divider-color);
    background: var(--bg-color);
    /* Slight contrast from card */
    color: var(--text-primary);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.password-input-wrapper {
    position: relative;
    width: 100%;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    font-size: 14px;
    transition: color 0.2s, transform 0.2s;
}

.toggle-password:hover {
    color: var(--brand-primary);
    transform: translateY(-50%) scale(1.1);
}

.toggle-password:active {
    transform: translateY(-50%) scale(0.9);
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.btn-primary:active {
    opacity: 0.8;
}

.lang-option {
    padding: 14px 18px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.lang-option:hover {
    background: rgba(var(--brand-primary-rgb), 0.05);
}

.lang-option.active {
    background: rgba(var(--brand-primary-rgb), 0.1);
    color: var(--brand-primary);
    font-weight: 600;
}

.lang-option span {
    font-size: 15px;
}

.lang-option small {
    display: block;
}

/* --- HANGING MOON (DARK MODE ONLY) --- */
.hanging-moon-container {
    position: absolute;
    top: 100%;
    /* Attach to bottom of nav */
    right: 20px;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    align-items: center;
    z-index: 1001;
    pointer-events: none;
    transform-origin: top center;
    animation: moonSwing 4s ease-in-out infinite;
}

/* Show only in dark mode */
html.dark-mode .hanging-moon-container,
body.dark-mode .hanging-moon-container {
    display: flex;
}

.rope {
    width: 2px;
    height: 35px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0.2));
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
}

.moon {
    width: 32px;
    height: 32px;
    background: radial-gradient(circle at 30% 30%, #fdfcf0, #ebe29d);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(253, 252, 240, 0.4), inset -2px -2px 5px rgba(0, 0, 0, 0.2);
    margin-top: -2px;
}

.moon i {
    font-size: 14px;
    color: #2D3436;
    opacity: 0.3;
}

@keyframes moonSwing {

    0%,
    100% {
        transform: rotate(-5deg);
    }

    50% {
        transform: rotate(5deg);
    }
}

#moonToggle.retracting {
    animation: moonRetract 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards !important;
}

@keyframes moonRetract {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    30% {
        transform: translateY(15px) scale(1.1);
        opacity: 1;
    }

    100% {
        transform: translateY(-150px) scale(0.5);
        opacity: 0;
    }
}