:root {
    --bg-color: #ffffff00;
    --surface-color: #ffffff;
    --primary-color: #3b82f6;
    /* Bright Blue */
    --primary-hover: #2563eb;
    --text-main-light: #ffffff;
    --text-sub-light: #d1d5db;
    --text-sub: #9ca3af;
    --text-main-dark: #111827;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --shadow-soft: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-lg: 1rem;
    /* 16px */
    --radius-xl: 1.5rem;
    /* 24px */
    --radius-xxl: 2rem;
    /* 32px */
}

/* --- 2. GLOBAL RESET --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Fallback */
}

body {
    background: url('light.jpg') no-repeat center center / cover;
    color: var(--text-main-light);

    /* CRITICAL FIX: Use Dynamic Viewport Height for Mobile Chrome */
    height: 100dvh;
    width: 100vw;

    /* Lock body scroll completely. Only internal divs scroll. */
    overflow: hidden;

    display: flex;
    flex-direction: column;
}

/* Utilities */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 3. LOGIN SCREEN (index.html) --- */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
}

.login-card {
    background: var(--surface-color);
    padding: 2rem;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-card h1 {
    font-size: 1.75rem;
    margin-bottom: 1rem;
    color: var(--text-main-dark);
}

.login-card p {
    font-size: 0.9rem;
    margin-bottom: 2rem;
    color: var(--text-sub);
}

.login-icon {
    width: 80px;
    height: 80px;
    background-color: #eff6ff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 2rem auto;
}

.form-group {
    margin-bottom: 1.25rem;
}

.input-field {
    width: 100%;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    background-color: #ebeff4;
    border: 2px solid transparent;
    outline: none;
    transition: 0.2s;
    font-size: 1rem;
}

.input-field:focus {
    background-color: #fff;
    border-color: #bfdbfe;
}

.btn-primary {
    width: 100%;
    padding: 0.875rem;
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: 0.2s;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.auth-switch {
    margin-top: 15px;
    font-size: 0.8rem;
    color: #aaa;
    cursor: pointer;
}

.auth-switch:hover {
    color: var(--primary-color);
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* --- 4. DASHBOARD LAYOUT (Shared) --- */
.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    /* Fills the body's 100dvh */
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Header */
header {
    padding: 1rem 1.5rem 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    background-color: var(--bg-color);
    flex-shrink: 0;
    /* Prevents header from shrinking */
}

header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main-light);
}

#date-display {
    color: var(--text-sub-light);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    color: #666;
    cursor: pointer;
}

/* --- 5. MAIN CONTENT AREA --- */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 0 1.5rem;

    /* CHANGED: Add padding so content isn't hidden behind the fixed nav */
    /* padding-bottom: 100px;  */
    /* padding-bottom: 100px;     */

    position: relative;
}

/* SPECIAL CLASS: Add this to home.html content-area to lock stats at top */
.content-area.no-scroll {
    overflow: hidden;
}

/* Hide scrollbar for cleanness */
.content-area::-webkit-scrollbar {
    display: none;
}


/* Stats Cards (Home) */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
    /* Don't shrink stats */
}

.stat-card {
    background: var(--surface-color);
    padding: 1rem;
    border-radius: var(--radius-xxl);
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-label {
    font-size: 0.7rem;
    color: #484f5b;
    font-weight: 700;
}

.stat-val {
    font-size: 1.125rem;
    color: #000000;
    font-weight: 700;
}

.bg-orange {
    background: #ffedd5;
    color: #f97316;
}

.bg-blue {
    background: #dbeafe;
    color: #3b82f6;
}

/* Devices Grid */
.section-title {
    color: var(--text-main-light);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

/* Devices Grid — responsive auto-fill: fits as many cards as screen allows */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
    height: auto;
    overflow-y: auto;
    padding-bottom: 160px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Hide scrollbar */
.device-grid::-webkit-scrollbar {
    display: none;
}

/* No hard breakpoints needed — auto-fill handles all screen widths naturally */

/* --- 6. DEVICE CARD COMPONENT --- */
.device-card {
    background: var(--surface-color);
    padding: 1.25rem;
    border-radius: var(--radius-xxl);
    box-shadow: var(--shadow-soft);
    min-height: 160px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
    user-select: none;
    border: 2px solid transparent;
    position: relative;
    overflow: visible;
}

.device-card:active {
    transform: scale(0.96);
}

.device-card:hover {
    box-shadow: var(--shadow-hover);
}

.device-card.is-active {
    border-color: #dbeafe;
}

.device-card.has-timer {
    border-color: #f59e0b !important;
}

/* --- Fan Speed Slider (modal only, fan type) --- */
.modal-speed-wrap {
    padding: 4px 2px 0;
}

.speed-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 5px;
    background: #dbeafe;
    outline: none;
    cursor: pointer;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #3b82f6;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.35);
    cursor: pointer;
    transition: transform 0.1s;
}

.speed-slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.speed-slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #3b82f6;
    cursor: pointer;
}

.speed-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
}

.speed-labels span {
    font-size: 0.68rem;
    color: #9ca3af;
    font-weight: 600;
    width: 25%;
    text-align: center;
}

.speed-labels span:first-child {
    text-align: left;
}

.speed-labels span:last-child {
    text-align: right;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.device-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: background 0.3s, color 0.3s;
}

.icon-off {
    background: #f3f4f6;
    color: #424242;
}

.icon-on {
    background: var(--primary-color);
    color: white;
}

.device-name {
    white-space: nowrap;
    /* Keep name on one line */
    overflow: hidden;
    /* Hide extra text */
    text-overflow: ellipsis;
    /* Add ... at the end */
    width: 100%;
    /* Take full width of parent */
    display: block;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: #000000;
}

.device-status {
    font-size: 0.75rem;
    font-weight: 700;
}

.text-on {
    color: var(--primary-color);
}

.text-off {
    color: var(--text-sub);
}

/* Card Footer */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    margin-top: auto;
}

.footer-left {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Add this line: */
    min-width: 0;
    flex: 1;
}

.footer-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    text-align: right;
}

.runtime-display {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 500;
}

.is-active .runtime-display {
    color: #3b82f6;
}

.timer-display {
    font-size: 0.75rem;
    color: #f59e0b;
    font-weight: 700;
    background: #fef3c7;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Three Dots Menu */
.card-options {
    position: absolute;
    top: 15px;
    right: 15px;
    color: #4b5563;
    cursor: pointer;
    padding: 8px;
    z-index: 10;
    font-size: 1.1rem;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.card-options:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.1);
}

.device-card.is-active .card-options {
    color: #1e3a8a;
}

/* Offline & Loading States (Modern Ghost Style) */
.device-offline {
    pointer-events: none;
    opacity: 0.6;
    /* Dim the card */
    filter: grayscale(100%);
    /* Remove all color */
    background: #f9fafb;
    /* Optional: Make background slightly gray */
    border-color: #e5e7eb;
    /* Ensure border is dull */
    transition: all 0.3s ease;
}

/* HIDE the old overlay so we can see the icon/text */
.offline-overlay {
    display: none !important;
}

.spinner {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid #e5e7eb;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.card-loading {
    pointer-events: none;
    opacity: 0.8;
}

.card-loading .device-icon i {
    display: none;
}

.card-loading .spinner {
    display: block;
}


/* --- 7. BOTTOM NAVIGATION --- */
/* --- 7. BOTTOM NAVIGATION --- */
.bottom-nav {
    /* CHANGED: Use fixed to stick to screen bottom regardless of browser bars */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;

    z-index: 100;
    width: 100%;

    /* Optional: Add a subtle background gradient so text behind it doesn't clash */
    /* background: linear-gradient(to top, rgb(0, 0, 0) 0%, rgba(0, 0, 0, 0.721) 50%, rgba(0, 0, 0, 0.477) 75%, rgba(0, 0, 0, 0) 100%); */
    background: linear-gradient(90deg, rgb(149, 108, 172), rgb(63, 184, 198));

    /* Padding for iPhone Home Bar / Android Gestures */
    padding: 0.5rem 1.5rem calc(1rem + env(safe-area-inset-bottom)) 1.5rem;
}

.nav-inner {
    display: flex;
    justify-content: space-between;
    max-width: 500px;
    margin: 0 auto;
}

.nav-btn {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    cursor: pointer;
    width: 60px;
}

/* 1. INACTIVE STATE (Outline Look) */
.nav-btn i {
    font-size: 1.4rem;
    color: transparent;
    -webkit-text-stroke: 1.5px #ffffff;
    /* Gray/White outline */
    transition: all 0.2s ease;
}

.nav-btn span {
    font-size: 0.7rem;
    font-weight: 600;
    color: #ffffff;
}

/* 2. ACTIVE STATE (Filled Look) */
.nav-btn.active i {
    color: #fff;
    -webkit-text-stroke: 0px;
}

.nav-btn.active span {
    color: #ffffff;
}

/* Optional: Hover Effect */
.nav-btn:hover i {
    -webkit-text-stroke-color: #ffffff;
}

/* --- 8. MODALS --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-card {
    background: white;
    width: 90%;
    max-width: 400px;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-main-dark);
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
}

.modal-section {
    margin-top: 10px;
    margin-bottom: 20px;
    color: var(--text-main-dark);
}

.modal-section label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

/* Input with Icon */
.input-with-icon {
    position: relative;
}

.input-with-icon input {
    width: 100%;
    padding: 10px;
    padding-right: 40px;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.input-with-icon i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

/* Type Grid */
.type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.type-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 10px;
    border: 1px solid #eee;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #666;
    transition: 0.2s;
}

.type-option:hover {
    background: #b9b9b9;
}

.type-option.selected {
    background: #eff6ff;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* Timer Inputs */
.timer-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-row input {
    width: 10px;
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-align: center;
}

.timer-row span {
    font-size: 0.8rem;
    font-weight: 600;
    color: #9ca3af;
}

.btn-timer {
    background: #22c55e;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0 20px;
    height: 40px;
    font-weight: 600;
    cursor: pointer;
}

/* --- 9. ENERGY / HISTORY PAGE --- */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* --- 10. SETTINGS PAGE --- */
.settings-card {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.settings-card h3 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
}

.group-title {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-card {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    background: white;
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.profile-icon {
    width: 50px;
    height: 50px;
    background: #eff6ff;
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main-dark);
}

.role {
    font-size: 0.8rem;
    color: var(--text-sub);
}

.settings-btn {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    border: none;
    padding: 18px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    box-shadow: var(--shadow-soft);
    transition: 0.2s;
    margin-bottom: 10px;
}

.settings-btn:active {
    transform: scale(0.98);
}

.btn-text {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    color: #333;
}

.btn-text i {
    color: var(--primary-color);
    font-size: 1.1rem;
}

.settings-btn .fa-chevron-right {
    color: #ccc;
    font-size: 0.9rem;
}

.logout-btn {
    background-color: #fee2e2;
    color: #ef4444;
    margin-top: 30px;
}

.logout-btn:hover {
    background-color: #fecaca;
}

/* --- TOGGLE SWITCH STYLES --- */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: #4CAF50;
}

input:checked+.slider:before {
    transform: translateX(24px);
}


/* --- NEW MODERN SETTINGS STYLES --- */

/* 1. Device List Stack */
.device-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.device-list-card {
    background: white;
    padding: 15px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.device-list-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    border-color: #e5e7eb;
}

.device-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.device-icon-small {
    width: 42px;
    height: 42px;
    background: #f3f4f6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4b5563;
    font-size: 1.1rem;
}

.device-details {
    display: flex;
    flex-direction: column;
}

.device-id-text {
    font-weight: 600;
    color: #1f2937;
    font-size: 0.95rem;
}

.device-status-dot {
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.btn-remove {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: #fee2e2;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.btn-remove:hover {
    background: #ef4444;
    color: white;
}

/* 2. Action Grid (Side-by-Side Buttons) */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 15px;
    height: auto;
    /* Override old height */
    text-align: left;
    gap: 12px;
}

.action-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

.action-icon.green {
    background: #dcfce7;
    color: #16a34a;
}

.action-icon.blue {
    background: #dbeafe;
    color: #2563eb;
}

.action-text {
    display: flex;
    flex-direction: column;
}

.action-text .main {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
}

.action-text .sub {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 30px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    border: 2px dashed #cbd5e1;
    color: #94a3b8;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
}






/* --- UNIFIED SETTINGS LIST STYLES --- */

.settings-card-list {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    /* Ensures children don't overflow rounded corners */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
}

/* Common style for both Devices and Buttons in the list */
.list-item,
.list-item-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 20px;
    background: white;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    width: 100%;
    text-align: left;
    transition: background 0.2s;
}

.list-item:last-child,
.list-item-btn:last-child {
    border-bottom: none;
    /* Remove border for the last item */
}

.list-item-btn {
    cursor: pointer;
}

.list-item-btn:hover {
    background: #f9fafb;
}

/* Content Layout */
.btn-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.list-info {
    display: flex;
    flex-direction: column;
}

.list-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1f2937;
}

.list-sub {
    font-size: 0.8rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Icons */
.icon-box {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.icon-box.gray {
    background: #f3f4f6;
    color: #4b5563;
}

.icon-box.green {
    background: #dcfce7;
    color: #16a34a;
}

.icon-box.blue {
    background: #dbeafe;
    color: #2563eb;
}

/* Remove Button (Trash Icon) */
.btn-trash {
    background: #fee2e2;
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
}

.btn-trash:hover {
    background: #ef4444;
    color: white;
}

.arrow {
    color: #d1d5db;
    font-size: 0.9rem;
}

.list-item-placeholder {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 0.9rem;
}

/* --- SERVER SETTINGS STYLES --- */

.server-mode-toggle {
    display: flex;
    background: #f3f4f6;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.mode-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-weight: 600;
    font-size: 0.85rem;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mode-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.mode-btn:hover:not(.active) {
    color: #374151;
}

.mode-btn i {
    font-size: 0.85rem;
}

/* Server list items */
.server-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: white;
    border: none;
    border-bottom: 1px solid #f3f4f6;
    width: 100%;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
}

.server-list-item:last-child {
    border-bottom: none;
}

.server-list-item:hover {
    background: #f9fafb;
}

.server-list-item.selected {
    background: #eff6ff;
}

.server-list-item .server-url {
    font-size: 0.85rem;
    font-weight: 500;
    color: #374151;
    word-break: break-all;
    flex: 1;
}

.server-list-item .server-label {
    font-size: 0.7rem;
    color: #9ca3af;
    margin-top: 2px;
}

.server-list-item .server-check {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid #d1d5db;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: transparent;
    transition: all 0.2s;
    flex-shrink: 0;
    margin-left: 12px;
}

.server-list-item.selected .server-check {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Status badge */
.server-status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
}

.server-status-badge.online {
    background: #dcfce7;
    color: #16a34a;
}

.server-status-badge.offline {
    background: #fee2e2;
    color: #ef4444;
}

/* Countdown warning bar */
.server-countdown {
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #92400e;
    margin-bottom: 10px;
    animation: fadeIn 0.3s ease-out;
}

.server-countdown i {
    color: #f59e0b;
    font-size: 1rem;
}


.day-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid #ddd;
    background: white;
    cursor: pointer;
    font-weight: bold;
    transition: 0.3s;
}

.day-btn.selected {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}



/* =========================================
   VIEW TOGGLES & LIST VIEW STYLES (2-COLUMN COMPACT)
   ========================================= */

/* 1. Toggle Buttons (Unchanged) */
.view-toggles {
    display: flex;
    background: #f3f4f6;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.toggle-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    color: #9ca3af;
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: #ffffff;
    color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* 2. List View Container: 2-COLUMN GRID */
.device-grid.list-view {
    display: grid;
    /* Force 2 columns */
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding-bottom: 100px;
    height: auto;
}

/* 3. List View Card Transformation */
.device-grid.list-view .device-card {
    flex-direction: row;
    /* Horizontal layout */
    align-items: center;
    /* Vertically center items */
    justify-content: flex-start;
    min-height: 65px;
    /* Compact height */
    padding: 8px 12px;
    /* Tighter padding */
    gap: 10px;
}

/* 4. Ungroup Header */
.device-grid.list-view .card-header {
    display: contents;
}

/* 5. Icon Styling */
.device-grid.list-view .device-icon {
    order: 1;
    width: 36px;
    /* Smaller icon circle */
    height: 36px;
    font-size: 1rem;
    /* Smaller icon */
    margin: 0;
    flex-shrink: 0;
}

/* 6. Footer Layout (Name + Timer in Column) */
.device-grid.list-view .card-footer {
    display: flex;
    flex-direction: column;
    /* Stack Name and Info Vertically */
    align-items: flex-start;
    /* Left align */
    justify-content: center;
    order: 2;
    flex-grow: 1;
    background: transparent;
    padding: 0;
    margin: 0;
    width: auto;
    min-width: 0;
    gap: 2px;
    /* Space between Name and Timer */
}

/* HIDE the left wrapper's default behavior so we can customize children directly */
.device-grid.list-view .footer-left {
    display: contents;
    /* Ungroups this div so Name/Status are direct children of footer */
}

/* HIDE the Status Text ("ON/OFF") */
.device-grid.list-view .device-status {
    display: none !important;
}

/* Device Name Styling */
.device-grid.list-view .device-name {
    font-size: 0.9rem;
    margin-bottom: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* 7. Timer & Runtime Location (Moved below Name) */
.device-grid.list-view .footer-right {
    display: flex;
    flex-direction: row;
    /* Timers side-by-side if both exist */
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
    margin-top: 0;
    min-height: 14px;
    /* Reserve space even if empty to keep alignment */
}

/* Timer Text Styling */
.device-grid.list-view .runtime-display {
    font-size: 0.65rem;
    margin: 0;
    line-height: 1;
    white-space: nowrap;
}

/* HIDE Auto Off Timer in List View */
.device-grid.list-view .timer-display {
    display: none !important;
}

/* 8. Menu Dots (Far Right) */
.device-grid.list-view .card-options {
    order: 3;
    position: static;
    margin-left: auto;
    /* Push to right */
    width: auto;
    height: auto;
    padding: 0 0 0 5px;
    /* Little padding on left */
    flex-shrink: 0;
    font-size: 1rem;
}

/* ======================================== */
/* OTA UPDATE TOAST NOTIFICATION            */
/* ======================================== */
.ota-update-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-120px);
    z-index: 9999;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 92%;
    max-width: 440px;
    border-left: 5px solid #10b981;
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.3s ease;
}

.ota-update-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.ota-toast-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #059669;
    font-size: 1.3rem;
}

.ota-toast-body {
    flex: 1;
    min-width: 0;
}

.ota-toast-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #111827;
}

.ota-toast-version {
    font-size: 0.8rem;
    color: #6b7280;
    margin-top: 2px;
}

.ota-toast-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.ota-btn-update {
    background: #10b981;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.ota-btn-update:hover {
    background: #059669;
}

.ota-btn-later {
    background: #f3f4f6;
    color: #6b7280;
    border: none;
    padding: 8px 14px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
}

.ota-btn-later:hover {
    background: #e5e7eb;
    color: #374151;
}