/* ═══════════════════════════════════════════════════════════════
   CORE CSS — SmartInboxIA Modular Shell
   Variables, reset, header global, footer dots, swipe viewport.
   ⚠️ NE PAS MODIFIER CE FICHIER — Voir .agents/rules/modules.md
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-main: #0f0f23;
    --bg-header: #16213e;
    --bg-mascot: #0a0a1a;
    --bg-mail-item: #1a1a2e;
    --bg-selected: #2a2a4e;
    --bg-hover: #252540;
    --bg-detail: #111128;
    --bg-settings: #0d0d20;

    --col-cyan: #00d2ff;
    --col-yellow: #ffd32a;
    --col-white: #e0e0e0;
    --col-gray: #7f8fa6;
    --col-dark-gray: #666666;
    --col-green: #4cd137;
    --col-red: #e84118;

    --tag-urgent: #e84118;
    --tag-repondre: #4cd137;
    --tag-info: #0097e6;
    --tag-spam: #7f8fa6;

    --border: #1a1a3e;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    background: #000;
    height: 100%; width: 100%;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}

body {
    font-family: 'Montserrat', sans-serif;
    margin: 0; padding: 0;
    width: 1024px; height: 600px;
    min-width: 1024px; min-height: 600px;
    max-width: 1024px; max-height: 600px;
    overflow: hidden;
}

.screen {
    width: 100%; height: 100%;
    background: var(--bg-main);
    display: flex; flex-direction: column;
    overflow: hidden;
}

.hidden { display: none !important; }

/* ═══════════ GLOBAL HEADER ═══════════ */
.header {
    background: var(--bg-header);
    padding: 0 16px; height: 36px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    user-select: none;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header .title { color: var(--col-cyan); font-size: 13px; font-weight: 700; letter-spacing: 0.5px; }
.header-center { display: flex; gap: 6px; align-items: center; }
.header-right { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--col-white); }
.header-right .wifi { color: var(--col-yellow); font-size: 10px; }

.notif {
    background: var(--tag-urgent); color: white;
    padding: 1px 6px; border-radius: 8px;
    font-size: 9px; font-weight: 700; min-width: 18px; text-align: center;
}

/* Module name in header */
.current-module-name {
    color: var(--col-gray);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    opacity: 0.7;
}

.settings-btn {
    background: rgba(255,255,255,0.08); border: none;
    color: var(--col-gray); font-size: 16px;
    width: 28px; height: 28px; border-radius: 6px;
    cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.settings-btn:hover { background: rgba(255,255,255,0.15); color: var(--col-white); }
.settings-btn.active { background: rgba(0, 210, 255, 0.2); color: var(--col-cyan); }

/* ═══════════ MODULE VIEWPORT (SWIPE AREA) ═══════════ */
.module-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
}

.module-track {
    display: flex;
    height: 100%;
    will-change: transform;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.module-slide {
    height: 100%;
    overflow: hidden;
    flex-shrink: 0;
}

/* ═══════════ GLOBAL FOOTER — DOTS NAV ═══════════ */
.module-footer {
    background: var(--bg-header);
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 100;
    user-select: none;
}

.module-dot {
    background: rgba(255,255,255,0.06);
    border: 1px solid transparent;
    width: 28px; height: 20px;
    border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.25s ease;
    padding: 0;
}
.module-dot .dot-icon {
    font-size: 10px;
    opacity: 0.4;
    transition: opacity 0.25s;
    line-height: 1;
}
.module-dot:hover {
    background: rgba(255,255,255,0.12);
}
.module-dot:hover .dot-icon { opacity: 0.7; }
.module-dot.active {
    background: rgba(0, 210, 255, 0.15);
    border-color: rgba(0, 210, 255, 0.35);
    box-shadow: 0 0 8px rgba(0, 210, 255, 0.15);
}
.module-dot.active .dot-icon {
    opacity: 1;
    filter: drop-shadow(0 0 3px rgba(0, 210, 255, 0.5));
}

/* ═══════════ SETTINGS OVERLAY (GLOBAL) ═══════════ */
.settings-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    animation: settingsFadeIn 0.2s ease;
}
.settings-overlay.visible {
    display: flex;
}

@keyframes settingsFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.settings-container {
    display: flex; 
    width: 800px; 
    height: 480px; 
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.settings-left {
    width: 45%; padding: 20px; overflow-y: auto;
    border-right: 1px solid var(--border);
}
.settings-right {
    width: 55%; padding: 20px; overflow-y: auto;
    background: var(--bg-settings);
}
.settings-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.settings-title { color: var(--col-white); font-size: 14px; font-weight: 700; }
.settings-close-btn {
    background: rgba(232,65,24,0.15); border: 1px solid rgba(232,65,24,0.3);
    color: var(--col-red); padding: 4px 10px; border-radius: 6px;
    cursor: pointer; font-size: 10px; font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    transition: all 0.2s;
}
.settings-close-btn:hover { background: rgba(232,65,24,0.3); }

.setting-group {
    background: var(--bg-mail-item); border-radius: 8px;
    padding: 12px; margin-bottom: 12px;
}
.setting-group-title {
    color: var(--col-cyan); font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px;
}
.setting-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.03);
}
.setting-row:last-child { border-bottom: none; }
.setting-label { color: var(--col-gray); font-size: 11px; }
.setting-value { color: var(--col-white); font-size: 11px; font-weight: 600; }

.btn-action {
    background: rgba(0,210,255,0.12); border: 1px solid rgba(0,210,255,0.25);
    color: var(--col-cyan); padding: 8px 16px; border-radius: 6px;
    cursor: pointer; font-size: 11px; font-weight: 600;
    font-family: 'Montserrat', sans-serif; width: 100%;
    transition: all 0.2s; margin-top: 6px;
}
.btn-action:hover { background: rgba(0,210,255,0.2); }
.btn-action:active { transform: scale(0.98); }

/* ─── MODULE ORDER LIST (in Settings) ─── */
.module-order-list {
    display: flex; flex-direction: column; gap: 4px;
}
.module-order-item {
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-mail-item); padding: 8px 12px; border-radius: 6px;
    cursor: grab; user-select: none;
    transition: all 0.15s;
    border: 1px solid transparent;
}
.module-order-item:hover { background: var(--bg-hover); }
.module-order-item.dragging {
    opacity: 0.5; border-color: var(--col-cyan);
}
.module-order-item .order-icon { font-size: 14px; }
.module-order-item .order-name { color: var(--col-white); font-size: 11px; font-weight: 600; flex: 1; }
.module-order-item .order-handle { color: var(--col-dark-gray); font-size: 14px; cursor: grab; }

/* ─── TEST MODULE STYLES ─── */
.test-toggle-row {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-mail-item); padding: 10px 12px; border-radius: 8px;
    margin-bottom: 10px;
}
.test-toggle-label { color: var(--col-white); font-size: 12px; font-weight: 600; }

.toggle-switch { position: relative; width: 44px; height: 24px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: #333; border-radius: 24px; transition: 0.3s;
}
.toggle-slider::before {
    content: ""; position: absolute; height: 18px; width: 18px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--col-green); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

.setting-input {
    background: var(--bg-main); border: 1px solid var(--border);
    color: var(--col-white); padding: 4px 8px; border-radius: 4px;
    font-size: 11px; width: 60px; text-align: center;
    font-family: 'Montserrat', sans-serif;
}

.test-status {
    background: rgba(76,209,55,0.1); border: 1px solid rgba(76,209,55,0.3);
    border-radius: 6px; padding: 6px 12px; margin-bottom: 10px;
    display: flex; align-items: center; gap: 8px;
    font-size: 10px; color: var(--col-green);
}
.test-status-dot {
    width: 8px; height: 8px; background: var(--col-green);
    border-radius: 50%; animation: pulse 1.5s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.test-mail-list {
    display: flex; flex-direction: column; gap: 4px;
    max-height: 240px; overflow-y: auto; margin-bottom: 10px;
}
.test-mail-list::-webkit-scrollbar { width: 4px; }
.test-mail-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.test-mail-item {
    display: flex; align-items: center; gap: 8px;
    background: var(--bg-mail-item); padding: 6px 10px; border-radius: 6px;
    cursor: pointer; transition: all 0.15s;
}
.test-mail-item:hover { background: var(--bg-hover); }
.test-mail-item input[type="checkbox"] { accent-color: var(--col-cyan); width: 14px; height: 14px; cursor: pointer; }
.test-mail-item .test-mail-from { color: var(--col-cyan); font-size: 10px; font-weight: 600; min-width: 100px; }
.test-mail-item .test-mail-subject { color: var(--col-gray); font-size: 9px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn-send-test {
    background: linear-gradient(135deg, var(--col-green), #27ae60);
    border: none; color: white; font-weight: 700;
}
.btn-send-test:hover { box-shadow: 0 0 15px rgba(76,209,55,0.3); }

.test-log {
    background: rgba(0,0,0,0.3); border-radius: 6px;
    padding: 8px; max-height: 100px; overflow-y: auto; margin-top: 8px;
}
.test-log-title { color: var(--col-dark-gray); font-size: 9px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.test-log-entry { color: var(--col-gray); font-size: 9px; padding: 2px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.test-log-entry.success { color: var(--col-green); }
.test-log-entry.error { color: var(--col-red); }

/* ═══════════ ANIMATIONS ═══════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════ SHARED: Filter buttons (used by inbox header) ═══════════ */
.filter-btn {
    background: rgba(255,255,255,0.05); border: 1px solid transparent;
    color: var(--col-gray); padding: 3px 10px; border-radius: 12px;
    font-size: 10px; font-weight: 600; font-family: 'Montserrat', sans-serif;
    cursor: pointer; transition: all 0.2s;
}
.filter-btn:hover { background: rgba(255,255,255,0.1); }
.filter-btn.active { background: rgba(0,210,255,0.15); color: var(--col-cyan); border-color: rgba(0,210,255,0.3); }

/* ═══════════ SCROLLBAR GLOBAL ═══════════ */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
