/* =============================================
   RESET & BASE
   ============================================= */
   * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'B YEKAN', 'Segoe UI', 'Poppins', system-ui, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
    background: none;
    position: relative;
    font-size: 1rem;
    line-height: 1.5;
    transition: background-color 0.25s ease, color 0.2s ease;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =============================================
   VARIABLES (Light & Dark)
   ============================================= */
:root {
    --bg-body: #ffffff;
    --text-primary: #1a2c3e;
    --text-secondary: #2d3f52;

    --sidebar-bg: #ffffff;
    --sidebar-border: #e2e8f0;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --glass-bg: #ffffff;
    --badge-bg: #f1f5f9;
    --hover-bg: #f1f5f9;
    --input-bg: #ffffff;
    --input-border: #d1d5db;
    --modal-gradient-start: #ffffff;
    --modal-gradient-end: #f8fafc;
    --modal-border: #e2e8f0;
    --border-light: #e2e8f0;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    --toast-bg: rgba(255, 255, 255, 0.95);
    --topbar-bg: #ffffff;
    --primary-color: #2b98ff;

    --btn-glass-bg: #ffffff;
    --btn-glass-border: #e2e8f0;
    --btn-glass-text: #1a2c3e;
    --btn-glass-shadow: rgba(43, 152, 255, 0.05);
    --glass-primary-bg: #2b98ff;
    --glass-danger-bg: #fee2e2;
    --glass-warning-bg: #fef3c7;

    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);

    --alarm-default: #2b98ff;
    --alarm-warning: #eab308;
    --alarm-critical: #e11d48;
}

body.dark {
    --bg-body: #121212;
    --text-primary: #f3f4f6;
    --text-secondary: #cbd5e1;

    --sidebar-bg: #1e1e1e;
    --sidebar-border: #2d2d2d;
    --card-bg: #1e1e1e;
    --card-border: #2d2d2d;
    --glass-bg: #1e1e1e;
    --badge-bg: #2d2d2d;
    --hover-bg: #2d2d2d;
    --input-bg: #1e1e1e;
    --input-border: #3a3a3a;
    --modal-gradient-start: #1e1e1e;
    --modal-gradient-end: #2d2d2d;
    --modal-border: #3a3a3a;
    --border-light: #2d2d2d;
    --shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    --toast-bg: rgba(0, 0, 0, 0.85);
    --topbar-bg: #1e1e1e;
    --btn-glass-bg: #2d2d2d;
    --btn-glass-border: #3a3a3a;
    --btn-glass-text: #f3f4f6;
    --glass-primary-bg: #2b98ff;
    --glass-danger-bg: #3b1a1a;
    --glass-warning-bg: #3b2a1a;

    background-color: #121212;
}

/* =============================================
   MAIN LAYOUT
   ============================================= */
.main-content {
    transition: margin-right 0.3s ease-out;
    padding: calc(40px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 30px max(16px, env(safe-area-inset-left, 0px));
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    min-height: 100vh;
}

/* =============================================
   TOP BAR
   ============================================= */
.top-bar {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.global-header {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding-top: max(15px, env(safe-area-inset-top, 15px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

.global-header .header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1 1 auto;
    min-width: 0;
}

.global-header .header-left .menu-logo {
    height: 53px;
    width: 53px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    background: none !important;
    box-shadow: none;
    border: none;
}

.global-header .header-left .header-title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
    min-width: 0;
}

.global-header .header-left .header-title-group .main-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-primary);
    white-space: nowrap;
}

.global-header .header-left .header-title-group .sub-title {
    font-size: 0.85rem;
    font-weight: 400;
    color: var(--text-secondary);
    opacity: 0.8;
    white-space: nowrap;
}

.global-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.tab-bar {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    justify-content: center;
}

.tab-bar .tab-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 32px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: 0.2s;
    color: var(--btn-glass-text);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tab-bar .tab-btn.active {
    background: var(--glass-primary-bg) !important;
    color: #ffffff !important;
    border-color: var(--glass-primary-bg) !important;
    box-shadow: 0 4px 16px rgba(43, 152, 255, 0.15);
}

.tab-bar .tab-btn:hover:not(.active) {
    background: var(--hover-bg);
    transform: translateY(-1px);
}

/* =============================================
   SIDEBAR - نسخه نهایی و بی‌نقص
   ============================================= */
.sidebar {
    position: fixed;
    top: 40px;
    right: -320px;
    width: 85%;
    max-width: 280px;
    height: calc(100vh - 40px);
    height: calc(100dvh - 40px);
    background: var(--sidebar-bg);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.08);
    z-index: 1200;
    transition: right 0.3s ease-out;
    border-left: 1px solid var(--sidebar-border);
    border-radius: 30px 0 0 30px;
    padding: 16px 0 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.open {
    right: 10px;
}

/* ---------- هدر ثابت ---------- */
.sidebar-header {
    flex-shrink: 0;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: none;
}

.sidebar-header h3 {
    color: var(--text-primary) !important;
    font-weight: normal !important;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.sidebar-header h3 .logo-sidebar {
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background: none !important;
    box-shadow: none;
    border: none;
    object-fit: cover;
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px;
}

/* ---------- بخش میانی (اسکرول‌پذیر) ---------- */
.sidebar-scrollable {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 4px 8px 4px;
    width: 100%;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ---------- دکمه‌های پایین (ثابت) ---------- */
.bottom-sidebar-actions {
    flex-shrink: 0;
    background: var(--sidebar-bg);
    padding: 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-top: 1px solid var(--border-light);
    z-index: 5;
}

/* =============================================
   SIDEBAR BUTTONS
   ============================================= */
.dashboard-alarm-row,
.add-support-row,
.settings-row {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
}

.new-dashboard-btn,
.add-device-btn,
.settings-row .settings-btn {
    flex: 1;
    text-align: center;
    padding: 0 8px;
    height: 40px;
    line-height: 40px;
    border-radius: 32px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    font-size: 0.8rem;
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
    box-shadow: var(--shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    box-sizing: border-box;
}

.alarm-btn,
.support-btn,
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: 0.2s;
    flex-shrink: 0;
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    box-shadow: var(--shadow);
    box-sizing: border-box;
}

.alarm-btn { color: var(--alarm-default); }
.alarm-btn.warning { color: var(--alarm-warning); background: var(--glass-warning-bg) !important; border-color: #fef3c7 !important; }
.alarm-btn.critical { color: var(--alarm-critical); background: var(--glass-danger-bg) !important; border-color: #fee2e2 !important; animation: shake 0.6s infinite; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

.alarm-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.6rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    direction: ltr;
    box-shadow: 0 0 0 2px var(--card-bg);
}

.settings-row .settings-btn.update-alert {
    background: var(--glass-danger-bg) !important;
    border-color: #fee2e2 !important;
    color: #e11d48 !important;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* =============================================
   COLLAPSIBLE SECTIONS
   ============================================= */
.collapsible-section {
    margin: 0 12px 12px 12px;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    padding: 6px 0;
    font-weight: 600;
    color: var(--text-primary);
}

.section-header h4 {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

.toggle-icon {
    font-size: 0.7rem;
    transition: transform 0.2s;
}

.section-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    margin-top: 8px;
}

.section-content.collapsed {
    max-height: 0;
}

.empty-message {
    padding: 6px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-align: center;
}

/* =============================================
   DASHBOARD & DEVICE ITEMS
   ============================================= */
.dashboard-item,
.device-item {
    background: var(--card-bg);
    border-radius: 20px;
    margin: 6px 0;
    border: 1px solid var(--card-border);
    overflow: visible !important;
}

.dashboard-item {
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: 0.2s;
    overflow: hidden;
}

.dashboard-item:hover {
    background: var(--hover-bg);
    transform: translateX(-2px);
}

.dashboard-name {
    font-weight: 500;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.delete-dashboard {
    background: var(--glass-danger-bg);
    border: 1px solid #fee2e2;
    border-radius: 50%;
    color: #e11d48;
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.delete-dashboard:hover {
    background: #fee2e2;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.device-header i {
    color: var(--primary-color);
    margin-left: 8px;
}

.status-badge {
    font-size: 0.6rem;
    background: var(--badge-bg);
    padding: 2px 8px;
    border-radius: 20px;
}

.online { color: #10b981; }
.offline { color: #ef4444; }

.device-submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease;
    background: transparent;
}

.device-submenu.show {
    max-height: none;
    overflow: visible;
    padding: 4px 0;
}

.device-submenu li {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
    transition: 0.1s;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
}

.device-submenu li:hover {
    background: var(--hover-bg);
    padding-right: 28px;
}

.device-submenu li.delete-device-tab {
    color: #ef4444;
}
.device-submenu li.delete-device-tab i {
    color: #ef4444;
}

/* حذف خط زیر آخرین بخش سایدبار (فقط دستگاه‌ها) */
.sidebar-scrollable .collapsible-section:last-child {
    border-bottom: none !important;
    margin-bottom: 0 !important;
    padding-bottom: 4px !important;
}

/* =============================================
   GRID CARDS (Relay & Scenario)
   ============================================= */
.relay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 14px;
    width: 100%;
    margin-top: 20px;
}

.scenario-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 14px;
    width: 100%;
    margin-top: 20px;
}

.relay-card,
.scenario-card {
    background: var(--card-bg) !important;
    border-radius: 28px;
    padding: 18px 10px 14px;
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
    transition: all 0.3s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    will-change: transform, box-shadow;
}

.relay-card:hover,
.scenario-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow), 0 8px 28px rgba(0, 0, 0, 0.08);
}

.relay-card.on,
.scenario-card.on {
    background: var(--glass-primary-bg) !important;
    border: 1px solid var(--glass-primary-bg) !important;
    box-shadow: 0 4px 24px rgba(43, 152, 255, 0.2);
}

.relay-card.on:hover,
.scenario-card.on:hover {
    background: var(--glass-primary-bg) !important;
    box-shadow: 0 8px 32px rgba(43, 152, 255, 0.3);
}

body.dark .relay-card,
body.dark .scenario-card {
    background: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    box-shadow: var(--shadow);
}

body.dark .relay-card:hover,
body.dark .scenario-card:hover {
    background: var(--hover-bg) !important;
    box-shadow: var(--shadow), 0 8px 24px rgba(0, 0, 0, 0.3);
}

body.dark .relay-card.on,
body.dark .scenario-card.on {
    background: var(--glass-primary-bg) !important;
    border: 1px solid var(--glass-primary-bg) !important;
    box-shadow: 0 4px 24px rgba(43, 152, 255, 0.15);
}

body.dark .relay-card.on:hover,
body.dark .scenario-card.on:hover {
    box-shadow: 0 8px 32px rgba(43, 152, 255, 0.25);
}

/* Emoji */
.relay-emoji,
.scenario-emoji {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--badge-bg);
    margin: 0 auto 8px auto;
    font-size: 2rem;
    line-height: 1;
    transition: background 0.3s, transform 0.3s ease;
    border: 1px solid var(--card-border);
}

.relay-card:hover .relay-emoji,
.scenario-card:hover .scenario-emoji {
    transform: scale(1.1);
}

body.dark .relay-emoji,
body.dark .scenario-emoji {
    background: var(--badge-bg);
    border-color: var(--card-border);
}

.relay-card.on .relay-emoji,
.scenario-card.on .relay-emoji {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 24px rgba(43, 152, 255, 0.10);
}

body.dark .relay-card.on .relay-emoji,
body.dark .scenario-card.on .relay-emoji {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.15);
}

.relay-name,
.scenario-name {
    font-weight: 700;
    font-size: 0.9rem;
    word-break: break-word;
    max-width: 100%;
    margin-top: 4px;
}

.relay-card.on .relay-name,
.scenario-card.on .scenario-name,
.relay-card.on .scenario-number,
.scenario-card.on .scenario-number {
    color: #ffffff !important;
}

body.dark .relay-card.on .relay-name,
body.dark .scenario-card.on .scenario-name {
    color: #ffffff !important;
}

/* Edit icon */
.edit-icon {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: var(--badge-bg);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s, background 0.2s, transform 0.2s;
    font-size: 0.75rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
    border: 1px solid var(--card-border);
}

.relay-card:hover .edit-icon,
.scenario-card:hover .edit-icon {
    opacity: 0.85;
}

.edit-icon:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
}

/* ===== انیمیشن‌های دیگر (پاپ و سناریو) ===== */
@keyframes popEmoji {
    0% { transform: scale(1); }
    40% { transform: scale(1.8); }
    100% { transform: scale(1); }
}
.relay-emoji.pop { animation: popEmoji 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }

.scenario-card.running {
    animation: scenarioRun 0.6s ease;
}
@keyframes scenarioRun {
    0% { transform: scale(1); background: rgba(43, 152, 255, 0.05); }
    20% { transform: scale(1.05); background: rgba(43, 152, 255, 0.4); }
    45% { transform: scale(1.10); background: rgba(43, 152, 255, 0.7); }
    75% { transform: scale(1.03); background: rgba(43, 152, 255, 0.4); }
    90% { transform: scale(1); background: rgba(43, 152, 255, 0.15); }
    100% { transform: scale(1); background: rgba(43, 152, 255, 0); }
}

/* =============================================
   MODALS
   ============================================= */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 16px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.show {
    opacity: 1;
}

.modal-content {
    background: var(--modal-gradient-start);
    border-radius: 36px;
    padding: 20px 20px;
    width: 100%;
    max-width: 500px;
    direction: rtl;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.10);
    border: 1px solid var(--modal-border);
    transform: scale(0.95);
    transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.4, 1.1);
    color: var(--text-primary);
}

.modal.show .modal-content {
    transform: scale(1);
}

.modal-content h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 18px;
    text-align: center;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.form-group-modal {
    margin-bottom: 15px;
}
.form-group-modal label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.form-group-modal input,
.form-group-modal select {
    width: 100%;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    font-size: 0.9rem;
    transition: all 0.2s;
    outline: none;
    color: var(--text-primary);
}
.form-group-modal input[type="color"] {
    width: 100%;
    height: 40px;
    padding: 4px 8px;
}
.form-group-modal input:focus,
.form-group-modal select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(43, 152, 255, 0.08);
}

.color-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}
.color-row .form-group-modal {
    flex: 1;
    margin-bottom: 0;
}

.default-color-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 24px;
    padding: 8px 12px;
    color: var(--btn-glass-text);
    cursor: pointer;
    font-size: 0.8rem;
    margin-top: 8px;
    width: 100%;
    transition: 0.2s;
}
.default-color-btn:hover {
    background: var(--hover-bg);
}

.modal-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.modal-buttons button {
    flex: 1;
    padding: 10px 0;
    border: none;
    border-radius: 32px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 80px;
}

.save-btn-modal {
    background: var(--glass-primary-bg) !important;
    border: 1px solid var(--glass-primary-bg) !important;
    color: #ffffff !important;
}
.save-btn-modal:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.cancel-btn-modal {
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
}
.cancel-btn-modal:hover {
    background: var(--hover-bg) !important;
}

/* =============================================
   GLASS CARD (general)
   ============================================= */
.glass-card {
    background: var(--glass-bg);
    border-radius: 22px;
    padding: 16px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    width: 100%;
    overflow-x: auto;
}

/* =============================================
   BUTTONS (general)
   ============================================= */
button, .mgmt-btn {
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
    box-shadow: var(--shadow);
    border-radius: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.15s;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

button:hover, .mgmt-btn:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-2px);
}

.mgmt-btn {
    width: 100%;
    margin: 6px 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    text-align: right;
    line-height: 1.4;
    padding: 12px 16px;
    white-space: normal;
    word-break: break-word;
    position: relative;
}

.mgmt-btn .btn-icon {
    font-size: 1.1rem;
    margin-left: 8px;
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}
.mgmt-btn .btn-title {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 4px;
    padding-right: 28px;
}
.mgmt-btn .btn-desc {
    font-size: 0.7rem;
    opacity: 0.9;
    font-weight: normal;
    padding-right: 28px;
}

.mgmt-btn.danger {
    background: var(--glass-danger-bg) !important;
    border-color: #fee2e2 !important;
    color: #e11d48 !important;
}
.mgmt-btn.danger:hover {
    background: #fee2e2 !important;
}
.mgmt-btn.warning {
    background: var(--glass-warning-bg) !important;
    border-color: #fef3c7 !important;
    color: #e67e22 !important;
}
.mgmt-btn.warning:hover {
    background: #fef3c7 !important;
}
.mgmt-btn.secondary {
    background: var(--btn-glass-bg) !important;
    border-color: var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
}

/* =============================================
   LOGS
   ============================================= */
.log-entry {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 10px 14px;
    margin: 10px 0;
    border-right: 3px solid var(--primary-color);
    word-break: break-word;
    font-size: 0.85rem;
    border: 1px solid var(--card-border);
}

/* =============================================
   INPUTS
   ============================================= */
input, select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    padding: 8px 12px;
    width: 100%;
    margin: 6px 0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

/* =============================================
   TOAST
   ============================================= */
.toast {
    position: fixed;
    bottom: 16px;
    left: 16px;
    background: var(--toast-bg);
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 32px;
    font-size: 0.8rem;
    z-index: 1300;
    max-width: calc(100% - 32px);
    word-break: break-word;
    border: 1px solid var(--card-border);
}

/* =============================================
   MISC
   ============================================= */
.flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.schedule-item {
    background: var(--card-bg);
    border-radius: 18px;
    padding: 12px;
    margin: 10px 0;
    border-right: 4px solid var(--primary-color);
    position: relative;
    word-break: break-word;
    font-size: 0.85rem;
    border: 1px solid var(--card-border);
}

.schedule-delete-btn {
    background: var(--glass-danger-bg) !important;
    border: 1px solid #fee2e2 !important;
    border-radius: 24px;
    padding: 4px 10px;
    color: #e11d48 !important;
    cursor: pointer;
    margin-top: 8px;
    font-size: 0.75rem;
}
.schedule-delete-btn:hover {
    background: #fee2e2 !important;
}

.refresh-schedules-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 24px;
    padding: 4px 12px;
    color: var(--btn-glass-text);
    cursor: pointer;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.refresh-schedules-btn:hover {
    background: var(--hover-bg);
}

.device-select-card {
    text-align: center;
    cursor: pointer;
    border: 1px solid var(--card-border);
    border-radius: 22px;
    padding: 20px 16px;
    transition: 0.2s;
    background: var(--card-bg);
}

.layout-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

.layout-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 24px;
    padding: 6px 14px;
    color: var(--btn-glass-text);
    cursor: pointer;
    font-size: 0.85rem;
    transition: 0.2s;
}
.layout-btn:hover {
    background: var(--hover-bg);
}
.layout-btn.secondary {
    background: var(--input-bg);
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-right: none;
    padding-right: 0;
}
.dashboard-header h1 { display: none; }

.draggable .relay-card,
.draggable .scenario-card {
    cursor: grab;
}
.draggable .relay-card:active,
.draggable .scenario-card:active {
    cursor: grabbing;
}

.dashboard-checkboxes-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.dashboard-checkboxes-vertical label {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: flex-start;
}
.dashboard-checkboxes-vertical label input { margin: 0; order: 1; }
.dashboard-checkboxes-vertical label span { order: 0; }

.device-list-item {
    background: var(--card-bg);
    border-radius: 20px;
    margin: 8px 0;
    border: 1px solid var(--card-border);
    overflow: hidden;
}
.device-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    background: transparent;
    color: var(--text-primary);
}
.device-items-list {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: transparent;
}
.device-items-list.show {
    max-height: 300px;
    overflow-y: auto;
}
.device-items-list li {
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-top: 1px solid var(--border-light);
    cursor: pointer;
}
.device-items-list li input { width: auto; margin: 0; }

.scenario-settings-modal-content,
.advanced-modal-content { text-align: center; }
.scenario-settings-modal-content p,
.advanced-modal-content p {
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 20px;
}
.warning-icon {
    font-size: 2rem;
    color: #f59e0b;
    margin-bottom: 10px;
    text-align: center;
}

.all-relays-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}
.all-relays-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 32px;
    padding: 8px 20px;
    color: var(--btn-glass-text);
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    flex: 1;
    max-width: 180px;
}
.all-relays-btn.off { background: var(--input-bg); }
.all-relays-btn:hover {
    transform: translateY(-2px);
    background: var(--hover-bg);
}

.help-card {
    background: var(--glass-bg);
    border-radius: 22px;
    padding: 16px;
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow);
    margin-top: 20px;
}
.help-card h3 {
    font-size: 1rem;
    text-align: center;
    margin-bottom: 12px;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 8px;
}
.help-card p {
    font-size: 0.85rem;
    line-height: 1.6;
    margin-bottom: 12px;
    text-align: justify;
}
.help-card .support-btn-inline {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 32px;
    padding: 8px 16px;
    color: var(--btn-glass-text);
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    font-size: 0.85rem;
    display: inline-block;
    margin-top: 8px;
}
.help-card .support-btn-inline:hover {
    transform: translateY(-2px);
    background: var(--hover-bg);
}

.advanced-checkbox-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 0.85rem;
}
.advanced-checkbox-row input { width: auto; margin: 0; }

.client-id-display {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 0.7rem;
    opacity: 0.4;
    word-break: break-all;
    direction: ltr;
    font-family: monospace;
}

/* =============================================
   QR & SCANNER
   ============================================= */
.qr-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
}
.video-preview {
    width: 100%;
    max-width: 320px;
    border-radius: 20px;
    margin: 0 auto;
    display: block;
}
.scan-result {
    text-align: center;
    margin-top: 12px;
    font-size: 0.85rem;
}

/* =============================================
   VERSION & UPDATE
   ============================================= */
.version-text {
    opacity: 0.4;
    text-align: center;
    margin-top: 20px;
    font-size: 0.75rem;
    direction: ltr;
}

.update-warning {
    background: var(--glass-warning-bg);
    color: #e67e22;
    padding: 8px 12px;
    border-radius: 20px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.8rem;
    border: 1px solid #fef3c7;
}
.download-update-btn {
    background: var(--glass-primary-bg) !important;
    border-color: var(--glass-primary-bg) !important;
    color: #ffffff !important;
    margin-top: 6px;
}
.download-update-btn:hover {
    opacity: 0.85;
}

/* =============================================
   USER PERMISSIONS
   ============================================= */
.user-perm-detail {
    font-size: 0.75rem;
    background: var(--badge-bg);
    padding: 6px 8px;
    border-radius: 16px;
    margin-top: 4px;
}
.perm-badge {
    display: inline-block;
    background: var(--card-border);
    padding: 2px 8px;
    border-radius: 20px;
    margin: 2px;
    font-size: 0.7rem;
}
.perm-badge i { margin-left: 3px; }

/* =============================================
   NEWS
   ============================================= */
.news-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 14px 16px;
    margin: 12px 0;
    border-right: 6px solid;
    box-shadow: var(--shadow);
    transition: 0.2s;
    border: 1px solid var(--card-border);
}
.news-card.critical { border-right-color: #e11d48; background: rgba(225, 29, 72, 0.04); }
.news-card.high { border-right-color: #f97316; background: rgba(249, 115, 22, 0.04); }
.news-card.normal { border-right-color: var(--primary-color); background: rgba(43, 152, 255, 0.03); }
.news-card.low { border-right-color: #6b7280; background: rgba(107, 114, 128, 0.03); }

.news-card .news-title {
    font-size: 1rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.news-card .news-message {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}
.news-card .news-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.news-card .news-date {
    font-size: 0.7rem;
    color: var(--text-secondary);
    direction: ltr;
}
.news-card .news-buttons {
    display: flex;
    gap: 8px;
}
.news-card .news-link-btn,
.news-card .mark-read-btn {
    background: var(--btn-glass-bg);
    border: 1px solid var(--btn-glass-border);
    border-radius: 20px;
    padding: 4px 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: 0.2s;
    color: var(--btn-glass-text);
}
.news-card .news-link-btn:hover,
.news-card .mark-read-btn:hover {
    background: var(--hover-bg);
}
.news-card .mark-read-btn.marked {
    background: rgba(16, 185, 129, 0.12) !important;
    border-color: rgba(16, 185, 129, 0.15) !important;
    color: #10b981 !important;
}
.empty-news {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* =============================================
   SOCIAL
   ============================================= */
.social-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}
.social-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 32px;
    padding: 12px 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-primary);
    text-decoration: none;
    width: 100%;
    max-width: 280px;
    text-align: center;
}
.social-btn i { font-size: 1.2rem; }
.social-btn:hover {
    transform: translateY(-2px);
    background: var(--hover-bg);
    border-color: var(--primary-color);
}
.email-text {
    text-align: center;
    font-size: 1rem;
    background: var(--badge-bg);
    padding: 10px;
    border-radius: 32px;
    margin-top: 20px;
    word-break: break-all;
    font-family: monospace;
    border: 1px solid var(--card-border);
}
.support-description {
    text-align: center;
    margin: 10px 0 5px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--badge-bg);
    padding: 8px 12px;
    border-radius: 24px;
}

/* =============================================
   PASSCODE LOCK
   ============================================= */
.passcode-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
}
.passcode-box {
    background: var(--card-bg);
    border-radius: 32px;
    padding: 30px 20px;
    text-align: center;
    width: 280px;
    max-width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.10);
    border: 1px solid var(--card-border);
}
.passcode-box .logo-passcode {
    width: 100px;
    height: 100px;
    object-fit: contain;
    border-radius: 50%;
    background: transparent !important;
    box-shadow: none;
    margin-bottom: 16px;
}
.passcode-box .logo-passcode:hover {
    transform: scale(1.02);
    box-shadow: 0 0 30px rgba(43, 152, 255, 0.15), 0 0 60px rgba(43, 152, 255, 0.05);
}
.passcode-box input {
    text-align: center;
    font-size: 1.5rem;
    letter-spacing: 8px;
    direction: ltr;
}
.passcode-box button { margin-top: 16px; width: 100%; }

/* =============================================
   TOGGLE CHECKBOX / RADIO
   ============================================= */
.toggle-checkbox,
.toggle-radio,
.days-check-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 32px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: 0.2s;
    user-select: none;
    gap: 4px;
}
.toggle-checkbox.selected,
.toggle-radio.selected,
.days-check-item.selected {
    background: var(--glass-primary-bg) !important;
    border-color: var(--glass-primary-bg) !important;
    color: #ffffff !important;
}
input[type="checkbox"],
input[type="radio"] { display: none; }

.big-device-option {
    display: block;
    width: 100%;
    padding: 24px 16px;
    margin: 16px 0;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 32px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-primary);
}
.big-device-option i {
    font-size: 2rem;
    display: block;
    margin-bottom: 8px;
    color: var(--primary-color);
}
.big-device-option:hover {
    background: var(--hover-bg);
    transform: translateY(-3px);
    border-color: var(--primary-color);
}

/* =============================================
   SCROLLBAR
   ============================================= */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
    opacity: 0.3;
}
::-webkit-scrollbar-thumb:hover { opacity: 0.6; }

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

/* موبایل کوچک (تا 480px) */
@media (max-width: 480px) {
    .main-content { padding: 40px 8px 16px; }
    .global-header { padding: 10px 12px; }
    .global-header .header-left .menu-logo { height: 42px; width: 42px; }
    .global-header .header-left .header-title-group .main-title { font-size: 1rem; }
    .global-header .header-left .header-title-group .sub-title {
        font-size: 0.6rem;
        max-width: 100px;
    }
    .tab-bar .tab-btn { font-size: 0.65rem; padding: 4px 8px; }
    .relay-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .scenario-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
    .modal-content { padding: 16px; }
    
    .sidebar {
        top: 40px;
        bottom: 10px;
        width: 88%;
        max-width: 260px;
        height: calc(100vh - 40px - 10px);
        height: calc(100dvh - 40px - 10px);
        border-radius: 30px;
    }
    
    .mgmt-btn .btn-title { font-size: 0.8rem; }
    .mgmt-btn .btn-desc { font-size: 0.6rem; }
    .passcode-box { width: 90%; padding: 20px 16px; }
    .passcode-box .logo-passcode { width: 70px; height: 70px; }
    .news-card .news-title { font-size: 0.9rem; }
    .news-card .news-message { font-size: 0.8rem; }
}

/* موبایل متوسط و تبلت کوچک (481px - 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .main-content { padding: 65px 12px 20px; }
    .global-header .header-left .header-title-group .main-title { font-size: 1.2rem; }
    .global-header .header-left .header-title-group .sub-title {
        font-size: 0.75rem;
        max-width: 140px;
    }
    .relay-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .scenario-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
    .sidebar { width: 80%; max-width: 270px; }
}

/* تبلت بزرگ و دسکتاپ کوچک (769px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .relay-grid { grid-template-columns: repeat(3, 1fr); }
    .scenario-grid { grid-template-columns: repeat(4, 1fr); }
    .main-content { padding: 70px 20px 30px; }
}

/* دسکتاپ بزرگ (≥1025px) */
@media (min-width: 1025px) {
    .relay-grid { grid-template-columns: repeat(4, 1fr); }
    .scenario-grid { grid-template-columns: repeat(6, 1fr); }
    .main-content { padding: 20px 24px 40px; }
    .global-header .header-left .header-title-group .sub-title {
        max-width: 300px;
    }
}

/* جلوگیری از overflow در همه اندازه‌ها */
img, svg, video, canvas, iframe {
    max-width: 100%;
    height: auto;
}

/* تنظیمات لمسی برای موبایل */
body.sidebar-open {
    overflow: hidden;
    touch-action: none;
}

html, body {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

/* اجازه اسکرول در بخش‌های خاص */
.sidebar-scrollable,
.modal-content,
.device-submenu.show,
.device-items-list.show {
    touch-action: pan-y;
}

.sidebar,
.modal {
    touch-action: none;
}

/* =============================================
   یکسان‌سازی اجباری سایدبار - نهایی
   ============================================= */
.update-badge:empty {
    display: none !important;
}

.settings-row {
    display: flex !important;
    gap: 6px !important;
    align-items: center !important;
    width: 100% !important;
}

#newDashboardBtn,
#addDeviceBtn,
#settingsBtn {
    flex: 1 1 0 !important;
    min-width: 0 !important;
    height: 40px !important;
    min-height: 40px !important;
    padding: 0 8px !important;
    line-height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 0.8rem !important;
    font-weight: bold !important;
    border-radius: 32px !important;
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
    box-shadow: var(--shadow) !important;
    gap: 6px !important;
    box-sizing: border-box !important;
    text-align: center !important;
}

.alarm-btn,
.support-btn,
.theme-toggle {
    flex: 0 0 40px !important;
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
}

/* =============================================
   هم‌ارتفاع کردن سلکت و دکمه در فرم زمانبندی
   ============================================= */
#scheduleFormContainer select,
#scheduleFormContainer button {
    height: 44px !important;
    padding: 0 16px !important;
    font-size: 0.85rem !important;
    border-radius: 32px !important;
    box-sizing: border-box !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    margin: 6px 0 !important;
}

#scheduleFormContainer select {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--text-primary) !important;
    appearance: auto !important;
    -webkit-appearance: auto !important;
}

#scheduleFormContainer button {
    background: var(--btn-glass-bg) !important;
    border: 1px solid var(--btn-glass-border) !important;
    color: var(--btn-glass-text) !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: 0.15s !important;
}

#scheduleFormContainer button:hover {
    background: var(--hover-bg) !important;
    transform: translateY(-2px) !important;
}

/* =============================================
   افزایش فاصله بخش‌های فرم زمانبندی
   ============================================= */
#scheduleFormContainer {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

#scheduleFormContainer .flex-row {
    gap: 14px;
}

#scheduleFormContainer #relayChecks,
#scheduleFormContainer #daysCheck {
    gap: 12px;
}

#scheduleFormContainer #dateDiv .flex-row {
    gap: 14px;
}

#scheduleFormContainer > * {
    margin-bottom: 4px;
}

/* =============================================
   تغییر رنگ المان‌های انتخاب‌شده به آبی روشن
   ============================================= */
.toggle-checkbox.selected,
.toggle-radio.selected,
.days-check-item.selected {
    background: #23a6ff !important;
    border-color: #23a6ff !important;
    color: #ffffff !important;
}

.tab-bar .tab-btn.active {
    background: #23a6ff !important;
    border-color: #23a6ff !important;
    color: #ffffff !important;
}

.dashboard-checkboxes-vertical .toggle-checkbox.selected {
    background: #23a6ff !important;
    border-color: #23a6ff !important;
    color: #ffffff !important;
}

.device-items-list .toggle-checkbox.selected {
    background: #23a6ff !important;
    border-color: #23a6ff !important;
    color: #ffffff !important;
}

.relay-card, .scenario-card {
    touch-action: manipulation;
    cursor: pointer;
}

/* =============================================
   استایل دایره چشمک‌زن (افکت رادار)
   ============================================= */
.radar-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 30px auto;
    position: relative;
    width: 120px;
    height: 120px;
}
.radar-circle {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: #1a95e8;
    position: relative;
    z-index: 2;
    box-shadow: 0 0 30px rgba(26, 149, 232, 0.6);
    animation: pulse 0.38s ease-in-out infinite;
}
.radar-circle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(26, 149, 232, 0.25);
    z-index: -1;
    animation: radar 0.6s ease-out infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 30px rgba(26,149,232,0.6); }
    50% { transform: scale(1.15); box-shadow: 0 0 80px rgba(26,149,232,0.9); }
    100% { transform: scale(1); box-shadow: 0 0 30px rgba(26,149,232,0.6); }
}
@keyframes radar {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.7; }
    100% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
}

/* =============================================
   استایل نماد وایفای
   ============================================= */
.wifi-icon-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px auto;
}
.wifi-icon {
    width: 200px;
    height: 200px;
}
.wifi-dot {
    fill: #1a95e8;
    animation: none;
}
.wifi-arc {
    fill: none;
    stroke: #1a95e8;
    stroke-width: 10;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0;
}
.arc-1 {
    animation: fadeWifi1 4s ease-in-out infinite;
}
.arc-2 {
    animation: fadeWifi2 4s ease-in-out infinite;
}
.arc-3 {
    animation: fadeWifi3 4s ease-in-out infinite;
}
@keyframes fadeWifi1 {
    0% { opacity: 0; }
    10% { opacity: 0; }
    20% { opacity: 1; }
    45% { opacity: 1; }
    60% { opacity: 0; }
    100% { opacity: 0; }
}
@keyframes fadeWifi2 {
    0% { opacity: 0; }
    25% { opacity: 0; }
    35% { opacity: 1; }
    55% { opacity: 1; }
    70% { opacity: 0; }
    100% { opacity: 0; }
}
@keyframes fadeWifi3 {
    0% { opacity: 0; }
    40% { opacity: 0; }
    50% { opacity: 1; }
    70% { opacity: 1; }
    85% { opacity: 0; }
    100% { opacity: 0; }
}

/* =============================================
   استایل دایره با افکت نوری نرم
   ============================================= */
.light-effect-circle {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: #1a95e8;
    position: relative;
    margin: 25px auto;
    overflow: hidden;
    box-shadow: 
        0 0 40px rgba(26, 149, 232, 0.5),
        0 0 80px rgba(26, 149, 232, 0.25),
        0 0 120px rgba(26, 149, 232, 0.12);
    animation: glowPulse 3s ease-in-out infinite;
}
.light-effect-circle::after {
    content: '';
    position: absolute;
    top: -60%;
    left: -60%;
    width: 220%;
    height: 220%;
    background: radial-gradient(
        ellipse at 30% 30%, 
        rgba(255, 255, 255, 0.6) 0%, 
        rgba(255, 255, 255, 0) 55%
    );
    animation: rotateLight 5s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}
@keyframes rotateLight {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes glowPulse {
    0% { 
        box-shadow: 
            0 0 40px rgba(26,149,232,0.5),
            0 0 80px rgba(26,149,232,0.25),
            0 0 120px rgba(26,149,232,0.12);
    }
    50% { 
        box-shadow: 
            0 0 60px rgba(26,149,232,0.7),
            0 0 120px rgba(26,149,232,0.35),
            0 0 180px rgba(26,149,232,0.18);
    }
    100% { 
        box-shadow: 
            0 0 40px rgba(26,149,232,0.5),
            0 0 80px rgba(26,149,232,0.25),
            0 0 120px rgba(26,149,232,0.12);
    }
}

.support-btn-inline {
    background: #1a95e8 !important;
    color: #fff !important;
    border: none !important;
    padding: 8px 16px;
    border-radius: 32px;
    cursor: pointer;
    font-weight: bold;
}

.mgmt-btn .btn-icon {
    margin-left: 16px !important;
}

.scenario-number {
    font-size: 0.6rem;
    opacity: 0.7;
    margin-top: 4px;
    font-weight: 400;
}
.scenario-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
}
.scenario-card .scenario-emoji {
    order: 1 !important;
}
.scenario-card .scenario-number {
    order: 2 !important;
}
.scenario-card .scenario-name {
    order: 3 !important;
}

#menuToggleBtn {
    padding: 14px 12px !important;
    line-height: 1.2 !important;
    font-size: 1.4rem !important;
    background: transparent !important;
    border: none !important;
    color: var(--text-primary) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px !important;
}

#qrZoomBtn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    border-radius: 32px;
    background: var(--glass-primary-bg) !important;
    border: 1px solid var(--glass-primary-bg) !important;
    color: #ffffff !important;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
}
#qrZoomBtn:hover {
    opacity: 0.85;
    transform: translateY(-2px);
}

.qr-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 10px 0;
}
.qr-container img {
    max-width: 100% !important;
    height: auto !important;
}

/* =============================================
   iOS Install Guide (بدون blur)
   ============================================= */
#iosInstallGuide {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    min-height: 100vh !important;
    z-index: 999999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px !important;
    margin: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    animation: iosFadeIn 0.3s ease !important;
    transform: none !important;
    -webkit-transform: none !important;
    pointer-events: auto !important;
}

.ios-guide-overlay {
    display: contents !important;
}

.ios-guide-box {
    background: var(--card-bg) !important;
    border-radius: 36px !important;
    padding: 40px 28px 28px !important;
    max-width: 420px !important;
    width: 100% !important;
    position: relative !important;
    border: 1px solid var(--card-border) !important;
    box-shadow: var(--shadow) !important;
    animation: iosSlideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    margin: 0 auto !important;
    max-height: 85vh !important;
    overflow-y: auto !important;
    transform: none !important;
    -webkit-transform: none !important;
    text-align: center !important;
}

body.dark .ios-guide-box {
    background: var(--card-bg) !important;
    border-color: var(--card-border) !important;
    box-shadow: var(--shadow) !important;
}

.ios-guide-close {
    position: absolute !important;
    top: 14px !important;
    left: 18px !important;
    background: var(--badge-bg) !important;
    border: none !important;
    font-size: 1.3rem !important;
    color: var(--text-secondary) !important;
    cursor: pointer !important;
    padding: 6px 10px !important;
    border-radius: 50% !important;
    transition: 0.25s !important;
    line-height: 1 !important;
    width: 36px !important;
    height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ios-guide-close:hover {
    background: var(--hover-bg) !important;
    transform: rotate(90deg) !important;
}

@keyframes iosIconBounce {
    0%, 100% { transform: scale(1) rotate(-5deg); }
    50% { transform: scale(1.1) rotate(5deg); }
}

.ios-guide-box h3 {
    font-size: 1.4rem !important;
    font-weight: 800 !important;
    margin-bottom: 4px !important;
    color: var(--text-primary) !important;
    letter-spacing: -0.5px !important;
}

body.dark .ios-guide-box h3 {
    color: var(--text-primary) !important;
}

.ios-guide-box > p {
    font-size: 0.85rem !important;
    color: var(--text-secondary) !important;
    margin-bottom: 20px !important;
    line-height: 1.6 !important;
    opacity: 0.8 !important;
}

.ios-guide-steps {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    margin-bottom: 24px !important;
    text-align: right !important;
}

.ios-step {
    display: flex !important;
    align-items: center !important;
    gap: 14px !important;
    background: var(--badge-bg) !important;
    padding: 12px 16px !important;
    border-radius: 18px !important;
    border: 1px solid var(--card-border) !important;
    transition: 0.25s !important;
    text-align: right !important;
}

.ios-step:hover {
    background: var(--hover-bg) !important;
    transform: translateX(-4px) !important;
}

body.dark .ios-step {
    background: var(--badge-bg) !important;
    border-color: var(--card-border) !important;
}

body.dark .ios-step:hover {
    background: var(--hover-bg) !important;
}

.ios-step-num {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 30px !important;
    height: 30px !important;
    border-radius: 50% !important;
    background: var(--primary-color) !important;
    color: #ffffff !important;
    font-size: 0.7rem !important;
    font-weight: 700 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 4px 12px rgba(43, 152, 255, 0.2) !important;
}

body.dark .ios-step-num {
    box-shadow: 0 4px 12px rgba(43, 152, 255, 0.1) !important;
}

.ios-step-text {
    font-size: 0.85rem !important;
    color: var(--text-primary) !important;
    line-height: 1.4 !important;
}

.ios-step-text strong {
    font-weight: 700 !important;
    color: var(--primary-color) !important;
}

body.dark .ios-step-text strong {
    color: #4ba5ff !important;
}

.ios-share-icon {
    display: inline-block !important;
    width: 22px !important;
    height: 22px !important;
    vertical-align: middle !important;
    margin: 0 4px !important;
    stroke: var(--primary-color) !important;
    flex-shrink: 0 !important;
    transition: 0.2s !important;
}

.ios-step:hover .ios-share-icon {
    transform: scale(1.15) !important;
}

body.dark .ios-share-icon {
    stroke: #4ba5ff !important;
}

.ios-guide-btn {
    width: 100% !important;
    padding: 16px !important;
    border: none !important;
    border-radius: 32px !important;
    background: var(--primary-color) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 1rem !important;
    cursor: pointer !important;
    transition: 0.3s !important;
    box-shadow: 0 4px 20px rgba(43, 152, 255, 0.3) !important;
    letter-spacing: 0.3px !important;
}

.ios-guide-btn:hover {
    opacity: 0.85 !important;
    transform: translateY(-3px) !important;
    box-shadow: 0 8px 32px rgba(43, 152, 255, 0.4) !important;
}

.ios-guide-btn:active {
    transform: scale(0.97) !important;
}

body.dark .ios-guide-btn {
    box-shadow: 0 4px 20px rgba(43, 152, 255, 0.15) !important;
}

body.dark .ios-guide-btn:hover {
    box-shadow: 0 8px 32px rgba(43, 152, 255, 0.25) !important;
}

.ios-guide-dismiss {
    display: block !important;
    width: 100% !important;
    margin-top: 12px !important;
    padding: 8px !important;
    background: none !important;
    border: none !important;
    color: var(--text-secondary) !important;
    font-size: 0.7rem !important;
    cursor: pointer !important;
    opacity: 0.4 !important;
    transition: 0.25s !important;
    text-decoration: none !important;
    font-weight: 400 !important;
}

.ios-guide-dismiss:hover {
    opacity: 0.8 !important;
}

/* ===== انیمیشن‌ها ===== */
@keyframes iosFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes iosSlideUp {
    from { transform: translateY(40px) scale(0.92); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

/* ===== ریسپانسیو ===== */
@media (max-width: 480px) {
    .ios-guide-box {
        padding: 28px 18px 20px !important;
        border-radius: 28px !important;
        max-width: 95% !important;
        margin: -10px auto 0 auto !important;
    }

    .ios-guide-icon {
        font-size: 3.2rem !important;
    }

    .ios-guide-box h3 {
        font-size: 1.15rem !important;
    }

    .ios-guide-box > p {
        font-size: 0.78rem !important;
        margin-bottom: 16px !important;
    }

    .ios-step {
        padding: 10px 12px !important;
        gap: 10px !important;
    }

    .ios-step-text {
        font-size: 0.78rem !important;
    }

    .ios-step-num {
        width: 26px !important;
        height: 26px !important;
        font-size: 0.6rem !important;
    }

    .ios-guide-btn {
        padding: 14px !important;
        font-size: 0.9rem !important;
    }

    .ios-guide-close {
        top: 10px !important;
        left: 12px !important;
        font-size: 1.1rem !important;
        width: 32px !important;
        height: 32px !important;
    }

    .ios-guide-steps {
        gap: 8px !important;
    }
}

@media (max-width: 380px) {
    .ios-guide-box {
        padding: 20px 14px 16px !important;
        border-radius: 24px !important;
    }

    .ios-guide-icon {
        font-size: 2.6rem !important;
    }

    .ios-guide-box h3 {
        font-size: 1rem !important;
    }

    .ios-step-text {
        font-size: 0.7rem !important;
    }
}

/* =============================================
   لوگو با افکت برق‌زدن (بدون blur)
   ============================================= */
.ios-guide-icon.ios-guide-logo {
    width: 90px !important;
    height: 90px !important;
    border-radius: 50% !important;
    object-fit: contain !important;
    background: transparent !important;
    display: inline-block !important;
    margin: 0 auto 12px auto !important;
    animation: iosLogoGlow 2.5s ease-in-out infinite !important;
    box-shadow: 0 0 30px rgba(43, 152, 255, 0.15) !important;
    transition: all 0.3s !important;
}

@keyframes iosLogoGlow {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(43, 152, 255, 0.15), 0 0 40px rgba(43, 152, 255, 0.05);
    }
    50% {
        transform: scale(1.06);
        box-shadow: 0 0 40px rgba(43, 152, 255, 0.4), 0 0 80px rgba(43, 152, 255, 0.15), 0 0 120px rgba(43, 152, 255, 0.05);
        filter: brightness(1.1);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(43, 152, 255, 0.15), 0 0 40px rgba(43, 152, 255, 0.05);
    }
}

body.dark .ios-guide-icon.ios-guide-logo {
    box-shadow: 0 0 30px rgba(43, 152, 255, 0.08) !important;
}

body.dark .ios-guide-icon.ios-guide-logo {
    filter: drop-shadow(0 0 20px rgba(43, 152, 255, 0.1));
}

@keyframes iosLogoGlowDark {
    0% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(43, 152, 255, 0.05);
    }
    50% {
        transform: scale(1.06);
        box-shadow: 0 0 40px rgba(43, 152, 255, 0.2), 0 0 80px rgba(43, 152, 255, 0.08);
        filter: brightness(1.15);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(43, 152, 255, 0.05);
    }
}

body.dark .ios-guide-icon.ios-guide-logo {
    animation-name: iosLogoGlowDark !important;
}

/* ===== محافظت از نوار پایین مرورگر در حالت عادی ===== */
.browser-mode .main-content {
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 20px)) !important;
}

.browser-mode .sidebar {
    bottom: calc(30px + env(safe-area-inset-bottom, 20px)) !important;
}

.browser-mode .toast {
    bottom: calc(30px + env(safe-area-inset-bottom, 20px)) !important;
}

.ios-guide-box {
    transform: translateY(-10%) !important;
}

@media (min-width: 1025px) {
    .global-header {
        padding-top: 12px !important;
        padding-bottom: 12px !important;
        padding-left: 0 !important;
    }
    
    #menuToggleBtn {
        align-self: center !important;
        padding: 8px 12px !important;
    }
}

/* ===== حذف هایلایت آبی هنگام لمس در اندروید ===== */
* {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    outline: none !important;
}

/* جلوگیری از نمایش outline آبی در فوکوس */
*:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* مخصوص دکمه‌ها و المان‌های قابل کلیک */
button,
a,
div[onclick],
[role="button"],
[data-tab],
.device-item,
.dashboard-item,
.relay-card,
.scenario-card,
.section-header,
.device-header,
.tab-btn,
.mgmt-btn,
.layout-btn,
.new-dashboard-btn,
.add-device-btn,
.settings-btn,
.alarm-btn,
.support-btn,
.theme-toggle,
.numpad-btn,
.close-sidebar,
.edit-icon,
.delete-dashboard,
.big-device-option,
.social-btn,
.ios-guide-btn,
.ios-guide-dismiss,
.ios-guide-close,
.toast {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    user-select: none !important;
    outline: none !important;
}

/* مخصوص مرورگرهای WebKit (Chrome, Samsung Internet, etc) */
input,
select,
textarea {
    -webkit-tap-highlight-color: transparent !important;
    outline: none !important;
}

/* جلوگیری از هایلایت آبی در لمس طولانی */
* {
    -webkit-touch-callout: none !important;
}

/* ===== بولد کردن عنوان سایدبار ===== */
.sidebar-header h3 {
    font-weight: 800 !important;
}