/* ── Alfred AI v1.2 — Full-Screen App CSS ───────────────────────────────────
   Zero WordPress leakage. Drawer-based settings. Mobile-first.
   Palette: #080D1A base · #0C1528 surface · #B87333 copper · #E8762C orange
──────────────────────────────────────────────────────────────────────────── */

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

html, body {
    height: 100%; width: 100%;
    overflow: hidden;
    background: #080D1A;
    color: #F0F2F5;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

/* ── App shell ───────────────────────────────────────────────────────────── */
#alfred-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    background: #080D1A;
    overflow: hidden;
    position: relative;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#alfred-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    height: 56px;
    min-height: 56px;
    background: #0C1528;
    border-bottom: 1px solid #1A2845;
    flex-shrink: 0;
    gap: 10px;
    z-index: 20;
}
.ah-left { display: flex; align-items: center; gap: 10px; }
.ah-right { display: flex; align-items: center; gap: 7px; }

/* Logo */
.alfred-logo { display: flex; align-items: center; gap: 9px; }
.hat-hh { width: 42px; height: 38px; filter: drop-shadow(0 0 8px rgba(184,115,51,.55)); animation: hat-glow 4s ease-in-out infinite; }
.hat-login { width: 90px; height: 82px; }
.hat-ih { width: 32px; height: 29px; }
@keyframes hat-glow { 0%,100%{filter:drop-shadow(0 0 6px rgba(184,115,51,.4))} 50%{filter:drop-shadow(0 0 20px rgba(212,144,74,.9))} }
.alfred-brand { display: flex; flex-direction: column; line-height: 1.15; }
.alfred-name {
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-size: 17px; font-weight: 700; letter-spacing: .07em;
    background: linear-gradient(135deg,#E8A84A 0%,#B87333 55%,#D4904A 100%);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.alfred-sub { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: #3A4D6E; }

/* AI pill */
.ai-pill {
    display: flex; align-items: center; gap: 7px;
    background: #141E34; border: 1px solid #1E2D52; border-radius: 20px;
    padding: 0 11px; height: 32px;
}
.ai-pill-dot { width: 7px; height: 7px; border-radius: 50%; background: #2A4A2A; flex-shrink: 0; transition: background .3s; }
.ai-pill-dot.online  { background: #3A9A5A; box-shadow: 0 0 6px rgba(58,154,90,.7); }
.ai-pill-dot.offline { background: #9A3A3A; }
.ai-pill select { background: transparent; border: none; color: #C8D0DC; font-size: 12px; font-weight: 500; outline: none; cursor: pointer; -webkit-appearance: none; appearance: none; }
.ai-pill select option { background: #141E34; }

/* Header icon buttons */
.hdr-btn {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid #1A2845; background: #0F1729; color: #5A6A8A;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all .2s; flex-shrink: 0; padding: 0;
}
.hdr-btn svg { width: 15px; height: 15px; }
.hdr-btn:hover  { border-color: #B87333; color: #D4904A; }
.hdr-btn.on     { border-color: #2A5A3A; color: #5ACA8A; background: #0A1E14; }
.hdr-btn.kill   { border-color: #2A5A2A; color: #5ACA5A; }
.hdr-btn.kill.engaged { border-color: #7A2020; color: #E05050; background: #1A0808; animation: kill-pulse 1.4s ease-in-out infinite; }
@keyframes kill-pulse { 0%,100%{box-shadow:0 0 0 0 rgba(224,80,80,0)} 50%{box-shadow:0 0 0 5px rgba(224,80,80,.18)} }

/* ── Body wrap ───────────────────────────────────────────────────────────── */
#alfred-body-wrap { display: flex; flex: 1; overflow: hidden; min-height: 0; }

/* ── Chat ────────────────────────────────────────────────────────────────── */
#alfred-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

#alfred-messages {
    flex: 1; overflow-y: auto; padding: 18px 16px 10px;
    display: flex; flex-direction: column; gap: 16px;
    scroll-behavior: smooth; overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
#alfred-messages::-webkit-scrollbar { width: 4px; }
#alfred-messages::-webkit-scrollbar-thumb { background: #1A2845; border-radius: 2px; }

/* Messages */
.msg { display: flex; gap: 10px; align-items: flex-start; animation: msg-in .28s cubic-bezier(.34,1.1,.64,1); }
@keyframes msg-in { from{opacity:0;transform:translateY(10px) scale(.97)} to{opacity:1;transform:none} }
.msg-user { flex-direction: row-reverse; }

.msg .hat-svg { width: 30px; height: 30px; flex-shrink: 0; background: #0E1A2E; border: 1px solid #B87333; border-radius: 50%; padding: 3px; filter: drop-shadow(0 0 5px rgba(184,115,51,.4)); }
.msg-user-av { width: 30px; height: 30px; flex-shrink: 0; background: linear-gradient(135deg,#1C2E4A,#0E1A2E); border: 1px solid #2A3D6A; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-size: 12px; font-weight: 700; color: #D4904A; }

.msg-bubble { max-width: 78%; padding: 11px 15px; border-radius: 14px; word-break: break-word; }
.msg-alfred .msg-bubble { background: #0C1830; border: 1px solid #162444; border-top-left-radius: 4px; }
.msg-user   .msg-bubble { background: #132040; border: 1px solid #1E3260; border-top-right-radius: 4px; }
.msg-bubble p { color: #CDD5E0; margin-bottom: 6px; line-height: 1.65; }
.msg-bubble p:last-of-type { margin-bottom: 0; }
.msg-bubble strong { color: #E8D0A0; }
.msg-bubble code { background: #0A1428; padding: 1px 5px; border-radius: 4px; font-size: 12px; color: #D4904A; }
.msg-meta { display: block; font-size: 10px; color: #3A4D6E; margin-top: 6px; }
.msg-img  { max-width: 240px; border-radius: 8px; margin-top: 8px; border: 1px solid #1A2845; display: block; }
.msg-file { display: inline-flex; align-items: center; gap: 6px; background: #0F1A30; border: 1px solid #1A2845; border-radius: 8px; padding: 6px 10px; font-size: 11px; color: #7A8AA0; margin-top: 8px; text-decoration: none; }
.msg-file:hover { border-color: #B87333; color: #D4904A; }
.msg-file svg { width: 12px; height: 12px; }

/* Typing */
.typing-wrap { display: flex; align-items: center; gap: 9px; padding: 3px 16px 6px; flex-shrink: 0; }
.typing-wrap .hat-svg { width: 26px; height: 26px; padding: 2px; }
.typing-dots { display: flex; align-items: center; gap: 4px; }
.typing-dots span { width: 6px; height: 6px; background: #B87333; border-radius: 50%; animation: tdot 1.2s ease-in-out infinite; }
.typing-dots span:nth-child(2){animation-delay:.18s} .typing-dots span:nth-child(3){animation-delay:.36s}
.typing-dots em { font-size: 11px; color: #4A5A7A; font-style: normal; margin-left: 4px; }
@keyframes tdot { 0%,80%,100%{transform:scale(.55);opacity:.3} 40%{transform:scale(1);opacity:1} }

/* Attach strip */
#alfred-attach-strip { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 16px; flex-shrink: 0; }
#alfred-attach-strip:empty { display: none; }
.att-thumb { position: relative; width: 50px; height: 50px; border-radius: 8px; background: #0F1A30; border: 1px solid #1A2845; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb .att-name { font-size: 8px; color: #6A7A9A; text-align: center; padding: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.att-rm { position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; background: rgba(0,0,0,.75); border-radius: 50%; border: none; color: #fff; cursor: pointer; font-size: 8px; display: flex; align-items: center; justify-content: center; }

/* Input area */
#alfred-input-area { padding: 9px 12px 12px; background: #090E1C; border-top: 1px solid #141E34; flex-shrink: 0; }
#alfred-toolbar { display: flex; align-items: center; gap: 5px; margin-bottom: 8px; }
.tool-btn { width: 28px; height: 28px; border-radius: 7px; border: 1px solid #141E34; background: transparent; color: #3A4D6E; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: all .2s; flex-shrink: 0; }
.tool-btn svg { width: 13px; height: 13px; }
.tool-btn:hover { border-color: #B87333; color: #D4904A; }
#alfred-token-badge { margin-left: auto; font-size: 10px; color: #2A3A5A; letter-spacing: .05em; }
#alfred-input-row { display: flex; gap: 8px; align-items: flex-end; }
#alfred-input {
    flex: 1; background: #0F1A30; border: 1px solid #1A2845; border-radius: 12px;
    color: #E0E8F0; font-size: 16px; /* 16px prevents iOS zoom */
    padding: 10px 14px; resize: none; outline: none; max-height: 120px;
    overflow-y: auto; transition: border-color .2s; line-height: 1.5;
    -webkit-overflow-scrolling: touch;
}
#alfred-input::placeholder { color: #2A3A5A; }
#alfred-input:focus { border-color: #B87333; }
#alfred-send {
    width: 42px; height: 42px; border-radius: 11px;
    background: linear-gradient(145deg,#C07A3A,#8B5A1A);
    border: none; color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: all .18s;
    box-shadow: 0 2px 10px rgba(184,115,51,.35);
}
#alfred-send:hover  { background: linear-gradient(145deg,#D4904A,#B87333); transform: scale(1.04); }
#alfred-send:active { transform: scale(.96); }
#alfred-send svg { width: 17px; height: 17px; }

/* ── Side panel ──────────────────────────────────────────────────────────── */
#alfred-side {
    width: 262px; flex-shrink: 0; background: #07101E;
    border-left: 1px solid #141E34; overflow-y: auto;
    padding: 14px 12px; display: flex; flex-direction: column; gap: 12px;
    -webkit-overflow-scrolling: touch;
}
#alfred-side::-webkit-scrollbar { width: 3px; }
#alfred-side::-webkit-scrollbar-thumb { background: #1A2845; border-radius: 2px; }

.side-card { background: #0C1528; border: 1px solid #141E34; border-radius: 11px; padding: 13px 13px 11px; }
.side-label { font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: #B87333; margin-bottom: 11px; padding-bottom: 7px; border-bottom: 1px solid #141E34; }

.status-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.status-list li { display: flex; align-items: center; gap: 8px; font-size: 11px; color: #6A7A9A; }
.sdot { width: 7px; height: 7px; border-radius: 50%; background: #1A2845; flex-shrink: 0; transition: background .3s; }
.sdot.online  { background: #3A9A5A; box-shadow: 0 0 5px rgba(58,154,90,.6); }
.sdot.offline { background: #8A3A3A; }
.sdot.warn    { background: #B87333; animation: hat-glow 1s ease-in-out infinite; }
.sval { margin-left: auto; font-size: 10px; color: #3A4D6E; }

.auto-btns { display: flex; gap: 5px; margin-bottom: 8px; }
.auto-btn { flex: 1; background: #0F1A30; border: 1px solid #1A2845; border-radius: 7px; color: #5A6A8A; cursor: pointer; padding: 7px 3px; display: flex; flex-direction: column; align-items: center; gap: 2px; transition: all .2s; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; }
.auto-btn strong { font-size: 14px; color: #3A4D6E; }
.auto-btn span   { font-size: 8px; text-transform: uppercase; letter-spacing: .09em; }
.auto-btn:hover  { border-color: #B87333; }
.auto-btn.active { border-color: #B87333; background: #14243C; }
.auto-btn.active strong { color: #D4904A; }
.auto-btn.active span   { color: #B87333; }
.auto-desc { font-size: 10px; color: #3A4D6E; line-height: 1.55; }

.qa-list { display: flex; flex-direction: column; gap: 5px; }
.qa-btn { background: #0A1428; border: 1px solid #141E34; border-radius: 7px; color: #7A8AA0; cursor: pointer; font-size: 11px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; padding: 7px 9px; text-align: left; transition: all .2s; line-height: 1.4; }
.qa-btn:hover { border-color: #B87333; color: #D4904A; background: #0F1A30; }

.mod-list { display: flex; flex-direction: column; gap: 6px; }
.mod-item {
    display: flex; align-items: center; gap: 10px;
    background: #0A1428; border: 1px solid #141E34; border-radius: 9px;
    padding: 9px 11px; transition: all .2s; cursor: default;
}
.mod-item:not(.soon):hover { border-color: #B87333; background: #0F1A30; cursor: pointer; }
.mod-item.soon { opacity: .6; }
.mod-icon { font-size: 16px; flex-shrink: 0; width: 22px; text-align: center; }
.mod-info { flex: 1; min-width: 0; }
.mod-info strong { display: block; font-size: 12px; color: #C8D0DC; font-weight: 600; }
.mod-info span { display: block; font-size: 10px; color: #3A4D6E; margin-top: 1px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mod-badge { font-size: 9px; color: #4A5A7A; background: #0F1729; border: 1px solid #1A2845; border-radius: 4px; padding: 2px 6px; white-space: nowrap; flex-shrink: 0; letter-spacing: .06em; text-transform: uppercase; }

/* Active Modules dashboard (Phase 1.2) */
.amod-list { display: flex; flex-direction: column; gap: 8px; }
.amod-loading { font-size: 11px; color: #3A4D6E; text-align: center; padding: 10px 0; margin: 0; }
.amod-card { background: #0A1428; border: 1px solid #141E34; border-radius: 9px; padding: 10px 11px; transition: border-color .2s; }
.amod-card:hover { border-color: #2A3A5E; }
.amod-head { display: flex; align-items: center; gap: 8px; }
.amod-name { font-size: 12px; color: #C8D0DC; font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amod-ver { font-size: 9px; color: #3A4D6E; flex-shrink: 0; }
.amod-state { font-size: 9px; color: #4A5A7A; background: #0F1729; border: 1px solid #1A2845; border-radius: 4px; padding: 2px 6px; flex-shrink: 0; letter-spacing: .06em; text-transform: uppercase; }
.amod-desc { font-size: 10px; color: #3A4D6E; margin: 6px 0 0; line-height: 1.4; }
.amod-details { margin-top: 8px; padding-top: 8px; border-top: 1px solid #141E34; display: flex; flex-direction: column; gap: 4px; }
.amod-row { display: flex; justify-content: space-between; gap: 8px; font-size: 10px; }
.amod-key { color: #4A5A7A; text-transform: capitalize; }
.amod-val { color: #8A9AB8; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%; }

/* Leads dashboard (Phase 2.4) */
.leads-filter { margin-bottom: 8px; }
.leads-filter select { width: 100%; background: #0A1428; border: 1px solid #1A2845; border-radius: 6px; color: #C8D0DC; font-size: 11px; padding: 6px 8px; }
.leads-list { display: flex; flex-direction: column; gap: 8px; }
.lead-actions { margin-top: 8px; padding-top: 8px; border-top: 1px solid #141E34; display: flex; gap: 6px; flex-wrap: wrap; }
.lead-btn { font-size: 10px; color: #C8D0DC; background: #0F1729; border: 1px solid #2A3A5E; border-radius: 5px; padding: 4px 9px; cursor: pointer; transition: border-color .2s; }
.lead-btn:hover { border-color: #E8964A; }
.lead-btn:disabled { opacity: 0.5; cursor: default; }
.lead-btn-reject:hover { border-color: #f87171; }

/* Keep old grid styles for any legacy references */
.mod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.mod-tile { background: #0A1428; border: 1px solid #141E34; border-radius: 7px; padding: 7px 5px; font-size: 10px; color: #3A4D6E; text-align: center; }
.mod-tile.soon { opacity: .55; }

/* ── Mobile tab bar ──────────────────────────────────────────────────────── */
#alfred-tabbar {
    display: none; /* shown on mobile */
    height: 54px; min-height: 54px;
    background: #08101E; border-top: 1px solid #141E34;
    flex-shrink: 0;
}
.tab { flex: 1; border: none; background: transparent; color: #3A4D6E; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 9px; letter-spacing: .06em; text-transform: uppercase; transition: color .2s; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; padding: 0; }
.tab svg { width: 17px; height: 17px; }
.tab.active { color: #D4904A; }
.tab.active svg { filter: drop-shadow(0 0 4px rgba(212,144,74,.5)); }

/* ══ SETTINGS DRAWER ════════════════════════════════════════════════════════ */
.drawer-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    z-index: 200; backdrop-filter: blur(2px);
    animation: fade-in .2s ease-out;
}
@keyframes fade-in { from{opacity:0} to{opacity:1} }

.drawer {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: min(480px, 100vw);
    background: #0A1020;
    border-left: 1px solid #1A2845;
    z-index: 201;
    display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: -8px 0 40px rgba(0,0,0,.6);
}
.drawer.open { transform: translateX(0); }

/* Drawer header */
.drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 18px;
    height: 56px; min-height: 56px;
    background: #0C1528;
    border-bottom: 1px solid #1A2845;
    flex-shrink: 0;
}
.drawer-title { display: flex; align-items: center; gap: 10px; font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-size: 14px; color: #D4904A; letter-spacing: .06em; }
.drawer-title .hat-svg { width: 28px; height: 28px; }
.drawer-close { width: 32px; height: 32px; border-radius: 8px; border: 1px solid #1A2845; background: #0F1729; color: #5A6A8A; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; transition: all .2s; }
.drawer-close:hover { border-color: #E05050; color: #E05050; }

/* Drawer scrollable body */
.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 18px 6px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}
.drawer-body::-webkit-scrollbar { width: 4px; }
.drawer-body::-webkit-scrollbar-thumb { background: #1A2845; border-radius: 2px; }

/* Drawer sections */
.drw-section { margin-bottom: 22px; }
.drw-section h3 {
    font-family: 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif; font-size: 10px; letter-spacing: .15em;
    text-transform: uppercase; color: #B87333;
    padding-bottom: 8px; border-bottom: 1px solid #141E34; margin-bottom: 14px;
}
.drw-hint { font-size: 11px; color: #3A4D6E; margin-bottom: 14px; line-height: 1.55; }

.drw-field { margin-bottom: 13px; }
.drw-field label {
    display: flex; align-items: center; gap: 6px;
    font-size: 11px; color: #7A8AA0; font-weight: 500; margin-bottom: 6px;
}
.drw-field label a { font-size: 10px; color: #4A5A7A; margin-left: auto; }
.drw-field label a:hover { color: #D4904A; }

.drw-field input[type="password"],
.drw-field input[type="text"],
.drw-field input[type="number"],
.drw-field select {
    width: 100%;
    background: #0F1A30; border: 1px solid #1A2845; border-radius: 9px;
    color: #E0E8F0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 15px; /* prevents iOS zoom */
    padding: 10px 13px; outline: none; transition: border-color .2s;
    -webkit-appearance: none; appearance: none;
}
.drw-field input:focus, .drw-field select:focus { border-color: #B87333; }
.drw-field small { font-size: 10px; color: #2A3A5A; line-height: 1.5; margin-top: 5px; display: block; }

.drw-toggle-row { display: flex; align-items: center; justify-content: space-between; }
.drw-toggle-row label { margin-bottom: 0; }

/* Toggle button */
.toggle-btn { width: 44px; height: 24px; background: #1A2845; border: 1px solid #2A3A5A; border-radius: 12px; cursor: pointer; position: relative; transition: all .25s; padding: 0; flex-shrink: 0; }
.toggle-btn span { position: absolute; width: 18px; height: 18px; border-radius: 50%; background: #3A4D6E; top: 2px; left: 2px; transition: all .25s; }
.toggle-btn.on { background: #B87333; border-color: #D4904A; }
.toggle-btn.on span { left: 22px; background: #fff; }

/* Audit log inside drawer */
#log-filter-row { display: flex; align-items: center; gap: 9px; margin-bottom: 11px; }
#log-filter { background: #0F1A30; border: 1px solid #1A2845; color: #E0E8F0; border-radius: 7px; padding: 6px 10px; font-size: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; outline: none; cursor: pointer; flex: 1; }
.drw-btn-danger { padding: 6px 13px; border-radius: 7px; border: 1px solid #5A1A1A; background: transparent; color: #E05050; font-size: 11px; cursor: pointer; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; transition: all .2s; white-space: nowrap; }
.drw-btn-danger:hover { background: #2A0808; }

#log-wrap { max-height: 280px; overflow-y: auto; border-radius: 8px; border: 1px solid #141E34; -webkit-overflow-scrolling: touch; }
#log-wrap::-webkit-scrollbar { width: 3px; }
#log-wrap::-webkit-scrollbar-thumb { background: #1A2845; border-radius: 2px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 10px; }
.log-table th { text-align: left; padding: 8px 10px; background: #0C1528; color: #3A4D6E; font-size: 9px; text-transform: uppercase; letter-spacing: .1em; border-bottom: 1px solid #141E34; position: sticky; top: 0; }
.log-table td { padding: 7px 10px; border-bottom: 1px solid #0C1528; color: #6A7A9A; vertical-align: top; }
.log-table tr:hover td { background: #0A1020; }
.log-empty { text-align: center; padding: 24px !important; color: #2A3A5A !important; }
.log-level { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.log-level.info    { background: #0A1E34; color: #4A8ABE; border: 1px solid #1A3A5A; }
.log-level.warning { background: #1E1400; color: #D4904A; border: 1px solid #4A3000; }
.log-level.error   { background: #2A0A0A; color: #E07070; border: 1px solid #5A1A1A; }

/* Settings notice */
.settings-notice { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 12px; background: #0C2A1A; border: 1px solid #2A5A3A; color: #5ACA8A; }
.settings-notice.error { background: #2A0C0C; border-color: #5A2A2A; color: #E07070; }

/* ── Drawer footer — STICKY SAVE BAR ────────────────────────────────────── */
.drawer-footer {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    background: #0C1528;
    border-top: 1px solid #1A2845;
    flex-shrink: 0;
    /* Always visible at bottom, never scrolled away */
}
.save-btn {
    flex: 1;
    padding: 13px 20px;
    background: linear-gradient(135deg,#B87333,#8B5A1A);
    border: none; border-radius: 10px;
    color: #fff; font-weight: 600; font-size: 15px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif; cursor: pointer;
    transition: all .2s;
    box-shadow: 0 2px 12px rgba(184,115,51,.35);
}
.save-btn:hover { background: linear-gradient(135deg,#D4904A,#B87333); }
.save-btn:active { transform: scale(.98); }
#save-status { font-size: 12px; color: #5ACA8A; white-space: nowrap; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.alfred-toast {
    position: fixed; bottom: 70px; left: 50%; transform: translateX(-50%);
    background: #0C1E30; border: 1px solid #1A3A5A; color: #9ABACE;
    padding: 9px 18px; border-radius: 20px; font-size: 12px; z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,.5); white-space: nowrap;
    animation: toast-in .22s ease-out; pointer-events: none;
}
.alfred-toast.err { background: #2A0A0A; border-color: #5A1A1A; color: #E07070; }
@keyframes toast-in { from{opacity:0;transform:translateX(-50%) translateY(8px)} to{opacity:1;transform:translateX(-50%) translateY(0)} }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 860px) {
    #alfred-side { display: none; }
    #alfred-tabbar { display: flex; }
    /* Side panel shown via JS adding .side-visible class */
    #alfred-side.side-visible {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0; right: 0;
        bottom: 54px;
        width: 100% !important;
        overflow-y: auto !important;
        z-index: 5;
        border-left: none;
    }
    /* Hide all side cards by default — JS shows only the active one */
    #alfred-side .side-card { display: none; }
    #alfred-side .side-card.panel-active { display: block; }
    #panel-crm.panel-active { display: block; }
    .alfred-sub { display: none; }
    .drawer { width: 100vw; border-left: none; }
}

@media (max-width: 480px) {
    #alfred-messages { padding: 12px 12px 8px; gap: 13px; }
    .msg-bubble { max-width: 85%; padding: 10px 12px; }
    #alfred-input-area { padding: 8px 10px 10px; }
    .hdr-btn { width: 31px; height: 31px; }
    .alfred-name { font-size: 15px; }
    .ai-pill { padding: 0 8px; }
}

/* ── Phase 2.5 Additions ─────────────────────────────────────────────────── */

/* Module badges — Running state */
.mod-item.running { opacity: 1; }
.mod-item.running:hover { border-color: #22c55e; background: #0F1A30; cursor: default; }
.mod-badge-running {
    background: rgba(34, 197, 94, 0.12) !important;
    color: #22c55e !important;
    border: 1px solid rgba(34, 197, 94, 0.3) !important;
    font-size: 9px;
    animation: pulse-green 2.5s ease-in-out infinite;
}
@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.65; }
}

/* Mic button */
.mic-btn {
    background: none;
    border: 1px solid #1A2845;
    border-radius: 8px;
    color: #6B7A99;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    transition: all .2s;
}
.mic-btn:hover { border-color: #B87333; color: #B87333; }
.mic-btn.mic-on {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239,68,68,.1);
    animation: mic-pulse 1s ease-in-out infinite;
}
@keyframes mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
    50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Input row spacing for mic button */
#alfred-input-row {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

/* Past Conversations panel */
#panel-past-convs { padding: 0; overflow: hidden; }
#panel-past-convs .side-label { padding: 14px 16px 10px; margin: 0; }
#past-conv-list { overflow-y: auto; max-height: 500px; padding: 0 0 8px; }

.conv-date-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #4A5A7A;
    padding: 10px 16px 4px;
    margin-top: 4px;
}
.conv-item {
    padding: 10px 16px;
    border-bottom: 1px solid rgba(255,255,255,.04);
    cursor: pointer;
    transition: background .15s;
}
.conv-item:hover, .conv-item-active {
    background: rgba(184,115,51,.08);
    border-left: 2px solid #B87333;
}
.conv-item-time {
    font-size: 10px;
    color: #4A5A7A;
    margin-bottom: 3px;
}
.conv-item-preview {
    font-size: 12px;
    color: #C8D0E0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}
.conv-item-meta {
    font-size: 10px;
    color: #3A4A6A;
}

/* Conversation session overlay */
.conv-session-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(5,10,25,.85);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.conv-session-panel {
    background: #0D1526;
    border: 1px solid #1A2845;
    border-radius: 14px;
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.conv-session-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #1A2845;
    font-size: 13px;
    font-weight: 600;
    color: #B87333;
}
.conv-close-btn {
    background: none;
    border: none;
    color: #4A5A7A;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color .15s;
}
.conv-close-btn:hover { color: #C8D0E0; }
.conv-session-msgs {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.conv-msg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.conv-msg-alfred { flex-direction: row; }
.conv-msg-user   { flex-direction: row-reverse; }
.conv-msg-av { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.conv-msg-body { max-width: 80%; }
.conv-msg-meta {
    font-size: 10px;
    color: #4A5A7A;
    display: block;
    margin-bottom: 4px;
}
.conv-msg-text {
    background: #111D35;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    color: #C8D0E0;
    line-height: 1.5;
}
.conv-msg-user .conv-msg-text { background: #1A2B50; text-align: right; }
.conv-session-footer {
    padding: 12px 16px;
    border-top: 1px solid #1A2845;
}

/* ── Tab links (CRM, History as real page links) ─────────────────────────── */
#alfred-tabbar a.tab {
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ── History page — conversation list enhancements ───────────────────────── */
.conv-item-actions { margin-top: 6px; }
.conv-resume-btn {
    display: inline-block;
    font-size: 10px;
    color: #B87333;
    background: rgba(184,115,51,.1);
    border: 1px solid rgba(184,115,51,.3);
    border-radius: 5px;
    padding: 3px 10px;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
    transition: all .15s;
}
.conv-resume-btn:hover { background: rgba(184,115,51,.25); }
.conv-item-active { border-left: 3px solid #22c55e !important; }

/* ── History page — save/delete actions ──────────────────────────────────── */
.conv-item { cursor: default; }
.conv-item-main { cursor: pointer; flex: 1; }
.conv-item { display: flex; align-items: center; gap: 8px; }
.conv-item-saved { border-left: 3px solid #f59e0b !important; }
.conv-action-btn {
    background: none;
    border: 1px solid #1A2845;
    border-radius: 5px;
    color: #4A5A7A;
    cursor: pointer;
    font-size: 13px;
    padding: 3px 7px;
    line-height: 1;
    transition: all .15s;
    flex-shrink: 0;
}
.conv-action-btn:hover { border-color: #B87333; color: #D4904A; }
.conv-delete-btn:hover { border-color: #ef4444; color: #ef4444; }
.conv-item-actions { display: flex; gap: 4px; align-items: center; flex-shrink: 0; }

/* ── 2.9.6 Module Check / Diagnostics ─────────────────────────────────── */
.diag-hint { font-size: 11px; color: #5A6D8E; line-height: 1.5; margin: 0 0 8px; }
.diag-opt { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #7A8AA0; margin: 0 0 6px; cursor: pointer; }
.diag-opt input { accent-color: #B87333; }
.diag-run-btn { width: 100%; text-align: center; font-weight: 600; margin: 6px 0 10px; padding: 9px; }
.diag-results { display: flex; flex-direction: column; gap: 6px; }
.diag-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.diag-chip { font-size: 10px; padding: 3px 8px; border-radius: 20px; border: 1px solid #141E34; color: #C7D0E0; }
.diag-chip.diag-ok   { border-color: #1c5c3a; color: #4ade80; }
.diag-chip.diag-warn { border-color: #6b5411; color: #facc15; }
.diag-chip.diag-fail { border-color: #6b1f1f; color: #f87171; }
.diag-chip.diag-fixed{ border-color: #B87333; color: #D4904A; }
.diag-item.diag-ok      { border-left: 3px solid #4ade80; }
.diag-item.diag-warning { border-left: 3px solid #facc15; }
.diag-item.diag-fail    { border-left: 3px solid #f87171; }

/* ── 2.9.12 Per-module enable/disable toggle (Active Modules panel) ─────── */
.amod-toggle-btn {
    font-size: 9px; letter-spacing: .06em; text-transform: uppercase;
    padding: 3px 8px; border-radius: 4px; flex-shrink: 0; cursor: pointer;
    background: #1a1015; border: 1px solid #4a1f24; color: #f87171;
    transition: all .15s;
}
.amod-toggle-btn.on { background: #0F1729; border-color: #1c5c3a; color: #4ade80; }
.amod-toggle-btn:hover { filter: brightness(1.25); }
.amod-toggle-btn:disabled { opacity: .5; cursor: wait; }
