/* ============================================================
   Elevator Access Portal — portal-console.css
   New "command console" layout for index.php.
   Reuses existing hooks from portal.css (status-dot, status-pill,
   sip-dot, call-panel, chat bubbles, camera-frame, copy-toast) so
   portal.js keeps working unmodified for those pieces.
   ============================================================ */

* { box-sizing: border-box; }

body.console-body {
    margin: 0;
    min-height: 100vh;
    background: #eef1f4;
    color: #0f172a;
    font-family: 'IBM Plex Sans', 'Open Sans', system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

@keyframes blinkSlow { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }

/* ---- Header ---- */
.console-header {
    background: #0f172a;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 200;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.console-header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 11px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.console-header-left {
    display: flex;
    align-items: center;
    gap: 18px;
}
.console-logo { height: 34px; width: auto; display: block; }
.console-divider {
    width: 1px;
    height: 26px;
    background: rgba(255,255,255,.14);
}

/* ---- Elevator switcher ---- */
.switcher { position: relative; }
.switcher-btn {
    display: flex;
    align-items: center;
    gap: 11px;
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.13);
    padding: 7px 12px;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    text-align: left;
}
.switcher-btn:hover, .switcher-btn:focus { background: rgba(255,255,255,.11); color: #fff; text-decoration: none; }
.switcher-dot { width: 8px; height: 8px; border-radius: 50%; background: #4C9D38; flex: none; }
.switcher-name { display: block; font-weight: 600; font-size: 13px; line-height: 1.15; }
.switcher-meta { display: block; font-size: 11px; color: #94a3b8; line-height: 1.3; }
.switcher-caret { color: #94a3b8; margin-left: 2px; }

.switcher-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 340px;
    max-width: 90vw;
    background: #fff;
    color: #0f172a;
    border-radius: 13px;
    box-shadow: 0 18px 48px rgba(15,23,42,.28);
    overflow: hidden;
    z-index: 250;
    border: 1px solid #e2e8f0;
    padding: 0;
    margin: 0;
    list-style: none;
}
.switcher-menu-label {
    padding: 11px 15px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #64748b;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 7px;
}
.switcher-search-wrap { padding: 9px 15px; border-bottom: 1px solid #f1f5f9; }
.switcher-search-input {
    display: block; width: 100%; padding: 7px 10px; border: 1px solid #e2e8f0; border-radius: 8px;
    font-size: 12.5px; outline: none; color: #0f172a;
}
.switcher-search-input:focus { border-color: #186084; }
.switcher-no-results { padding: 16px; text-align: center; color: #94a3b8; font-size: 12.5px; }

.switcher-menu-list { max-height: 380px; overflow-y: auto; }
.switcher-row {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 11px 15px;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}
.switcher-row:hover { background: #f8fafc; text-decoration: none; color: inherit; }
.switcher-row.is-current { background: #e7f1f5; }
.switcher-row-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.switcher-row-name { display: block; font-weight: 600; font-size: 13px; }
.switcher-row-meta { display: block; font-size: 11px; color: #64748b; }
.switcher-row-icon { color: #186084; flex: none; }

/* ---- Header right: status badges ---- */
.console-header-right { display: flex; align-items: center; gap: 14px; }
.hdr-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 13px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.hdr-badge .status-dot { width: 8px; height: 8px; }
.hdr-badge.hdr-badge-idle   { background: rgba(255,255,255,.07); color: #cbd5e1; font-weight: 500; }
.hdr-badge.hdr-badge-active { background: rgba(76,157,56,.18); color: #a7e08f; }

.hdr-sip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-left: 14px;
    border-left: 1px solid rgba(255,255,255,.12);
    font-size: 12px;
    color: #94a3b8;
}

/* ---- Main grid ---- */
.console-main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px 24px 80px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    align-items: start;
}
.console-col-left   { grid-column: span 3; display: flex; flex-direction: column; gap: 18px; }
.console-col-center { grid-column: span 6; display: flex; flex-direction: column; gap: 18px; }
.console-col-right  { grid-column: span 3; }

/* When the center "Call Elevator" column is hidden (CALL_FEATURE_ENABLED
   false), Messages fills the freed space instead of leaving a gap. */
.console-col-right.console-col-right-wide { grid-column: span 9; }

@media (max-width: 1150px) {
    .console-col-left, .console-col-center, .console-col-right,
    .console-col-right.console-col-right-wide { grid-column: span 12; }
}

/* ---- Generic card ---- */
.cc-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
}
.cc-card-head {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    align-items: center;
    gap: 8px;
}
.cc-card-head h3 { font-size: 13.5px; font-weight: 600; margin: 0; }
.cc-card-head i.fa { color: #186084; width: 16px; }
.cc-card-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    color: #186084;
    background: #e7f1f5;
    padding: 2px 7px;
    border-radius: 5px;
    border: 1px solid #b9d8e3;
}

/* ---- Identity card ---- */
.identity-top {
    padding: 18px;
    background: linear-gradient(135deg,#0f172a,#1e293b);
    color: #fff;
}
.identity-top-inner { display: flex; align-items: center; gap: 13px; }
.identity-icon {
    width: 48px; height: 48px;
    border-radius: 11px;
    background: rgba(24,96,132,.24);
    border: 1px solid rgba(24,96,132,.5);
    display: flex; align-items: center; justify-content: center;
    flex: none;
    color: #7cc1dc;
    font-size: 20px;
}
.identity-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; margin: 0; }
.identity-name { font-size: 19px; font-weight: 700; margin: 2px 0 0; line-height: 1.1; }

.identity-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.identity-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.identity-field-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
    color: #94a3b8; font-weight: 600; margin: 0;
}
.identity-field-value { font-size: 14px; font-weight: 500; margin: 3px 0 0; color: #1e293b; word-break: break-word; }
.mono { font-family: 'IBM Plex Mono', monospace; }

.line-service-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.line-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 22px; height: 22px; padding: 0 7px;
    border-radius: 11px; background: #eff6ff; color: #1d4ed8;
    font-size: 12px; font-weight: 700; font-family: 'IBM Plex Mono', monospace;
    border: 1px solid #bfdbfe;
}

/* ---- Static URL card ---- */
.static-url-body { padding: 16px; }
.static-url-hint { font-size: 11.5px; color: #64748b; margin: 0 0 8px; }
.static-url-box {
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
    padding: 10px; font-size: 11.5px; font-family: 'IBM Plex Mono', monospace;
    color: #334155; line-height: 1.5;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.static-url-copy {
    margin-top: 10px; width: 100%; padding: 9px; font-size: 12.5px; font-weight: 600;
    background: #0f172a; color: #fff; border: none; border-radius: 8px; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 7px;
}
.static-url-copy:hover { background: #1e293b; color: #fff; }

/* ---- Emergency Contacts card ---- */
.ec-body { padding: 16px; display: flex; flex-direction: column; gap: 13px; }
.ec-row { display: flex; align-items: center; justify-content: space-between; }
.ec-row-divider { padding-top: 11px; border-top: 1px solid #f1f5f9; }
.ec-label { font-size: 12px; color: #64748b; margin: 0; }
.ec-value { font-size: 14px; font-weight: 600; margin: 2px 0 0; color: #1e293b; }
.ec-value-critical { color: #dc2626; }
.ec-icon { width: 16px; text-align: center; color: #94a3b8; }
.ec-icon-critical { color: #dc2626; }

/* ---- Hero (standby) card ---- */
.hero-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; overflow: hidden; }
.hero-top { background: linear-gradient(135deg,#0f172a,#1e293b); color: #fff; padding: 26px; }
.hero-top-inner { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.hero-eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; color: #94a3b8; margin: 0; }
.hero-name { font-size: 27px; font-weight: 700; margin: 7px 0 0; }
.hero-meta-row { display: flex; align-items: center; gap: 12px; margin-top: 14px; font-size: 13.5px; color: #cbd5e1; flex-wrap: wrap; }
.hero-meta-row .status-dot { animation: blinkSlow 1.6s infinite; }
.hero-icon {
    width: 62px; height: 62px; border-radius: 14px; background: rgba(24,96,132,.24);
    border: 1px solid rgba(24,96,132,.5); display: flex; align-items: center; justify-content: center;
    flex: none; color: #7cc1dc; font-size: 26px;
}

.hero-stats { display: grid; grid-template-columns: repeat(3,1fr); border-bottom: 1px solid #f1f5f9; }
.hero-stat { padding: 18px; text-align: center; border-right: 1px solid #f1f5f9; }
.hero-stat:last-child { border-right: none; }
.hero-stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: #94a3b8; font-weight: 600; margin: 0; }
.hero-stat-value { font-size: 23px; font-weight: 700; margin: 5px 0 0; }
.hero-stat-value small { font-size: 13px; font-weight: 500; color: #94a3b8; }

.hero-cta { padding: 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.hero-call-btn {
    width: 100%; max-width: 380px; padding: 16px; background: #186084; color: #fff;
    font-weight: 600; font-size: 16px; border: none; border-radius: 13px;
    display: flex; align-items: center; justify-content: center; gap: 11px; cursor: pointer;
    box-shadow: 0 10px 26px rgba(24,96,132,.3);
}
.hero-call-btn:hover { background: #134f6b; color: #fff; }
.hero-call-hint { font-size: 12px; color: #94a3b8; margin: 0; }

/* ---- Streaming section: camera tabs -> viewer -> call controls ---- */
.console-cam-tabs { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.console-cam-tab {
    padding: 8px 13px; background: #fff; border: 1px solid #e2e8f0; color: #64748b;
    border-radius: 9px; font-size: 13px; display: flex; align-items: center; gap: 8px; cursor: pointer;
}
.console-cam-tab:hover { border-color: #cbd5e1; }
.console-cam-tab.is-active { border: 1.5px solid #0f172a; color: #0f172a; font-weight: 600; }

.console-cam-viewer {
    position: relative; border-radius: 14px; overflow: hidden; border: 1px solid #e2e8f0;
    aspect-ratio: 16 / 9; background: #0b1220;
}
.console-cam-frame {
    position: absolute; inset: 0; width: 100%; height: 100%; border: none; display: none;
    /* Scale iframe content to fill the viewer, hiding native-res overflow */
    object-fit: cover;
}
.console-cam-frame.is-active { display: block; }
.console-cam-live {
    position: absolute; top: 12px; left: 12px; z-index: 2; display: flex; align-items: center; gap: 7px;
    background: #dc2626; padding: 5px 9px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .05em;
}
.console-cam-live span { width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: blinkSlow 1.4s infinite; }
.console-cam-index {
    position: absolute; top: 12px; right: 12px; z-index: 2; background: rgba(0,0,0,.6); padding: 5px 9px;
    border-radius: 6px; color: #fff; font-size: 11px; font-family: 'IBM Plex Mono', monospace;
}
.console-cam-time {
    position: absolute; bottom: 12px; left: 12px; z-index: 2; background: rgba(0,0,0,.6); padding: 5px 9px;
    border-radius: 6px; color: #fff; font-size: 11px; font-family: 'IBM Plex Mono', monospace;
}
.console-cam-empty {
    position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
    color: #475569; text-align: center; gap: 6px;
}
.console-cam-empty i { font-size: 40px; opacity: .6; }
.console-cam-empty p { margin: 4px 0 0; font-size: 13px; opacity: .75; }

.console-call-controls { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 16px; }
.console-call-controls-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.cc-ctrl-btn {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px;
    background: #f8fafc; border: 1px solid #eef2f6; border-radius: 10px; font-size: 12px; font-weight: 500;
    color: #334155; cursor: pointer;
}
.cc-ctrl-btn i { font-size: 20px; }
.cc-ctrl-btn:hover:not(:disabled) { background: #f1f5f9; }
.cc-ctrl-btn:disabled { opacity: .45; cursor: not-allowed; }
.cc-ctrl-btn.is-active { background: #e7f1f5; border-color: #b9d8e3; color: #13506a; }
.cc-ctrl-btn-danger { background: #dc2626; border: none; color: #fff; }
.cc-ctrl-btn-danger:hover:not(:disabled) { background: #b91c1c; }
.cc-ctrl-btn-danger:disabled { background: #dc2626; opacity: .45; }

/* ---- Messaging card ---- */
.console-msg-card {
    display: flex; flex-direction: column;
    height: calc(100vh - 200px); min-height: 420px; max-height: 680px;
}
.console-msg-tabs { display: flex; border-bottom: 1px solid #e2e8f0; }
.console-msg-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px; font-size: 13px; background: #fff; border: none; border-bottom: 2px solid transparent;
    cursor: pointer; color: #64748b;
}
.console-msg-tab.is-active { font-weight: 600; color: #0f172a; border-bottom-color: #186084; }

.console-msg-pane { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.console-msg-pane[hidden] { display: none; }

/* canned + input reuse portal.css classes visually but need tighter padding here */
.console-canned { border-top: 1px solid #e2e8f0; padding: 10px; background: #fff; }
.console-canned-label { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: #94a3b8; font-weight: 600; margin: 0 0 8px; }
.console-canned-list { display: flex; flex-wrap: wrap; gap: 6px; }
.console-canned-chip {
    padding: 5px 11px; background: #e7f1f5; border: 1px solid #b9d8e3; color: #13506a;
    font-size: 12px; border-radius: 999px; cursor: pointer;
}
.console-canned-chip:hover { background: #d6e8ef; }

.console-input-row { border-top: 1px solid #e2e8f0; padding: 10px; background: #fff; display: flex; align-items: flex-end; gap: 9px; }
.console-input-row textarea {
    flex: 1; resize: none; padding: 9px 11px; background: #f8fafc; border: 1px solid #e2e8f0;
    border-radius: 9px; font-size: 13.5px; font-family: inherit; outline: none; color: #0f172a;
}
.console-send-btn {
    width: 38px; height: 38px; background: #186084; border: none; border-radius: 9px; color: #fff;
    display: flex; align-items: center; justify-content: center; flex: none; cursor: pointer;
}
.console-send-btn:hover { background: #134f6b; }
.console-send-btn:disabled { background: #93c5fd; cursor: not-allowed; }

/* ---- History tab ---- */
.console-hist-list { background: #fff; }
.console-hist-row {
    display: block; width: 100%; text-align: left; padding: 13px 16px; border: none;
    border-bottom: 1px solid #f1f5f9; background: #fff; cursor: pointer;
}
.console-hist-row:hover { background: #f8fafc; }
.console-hist-row-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.console-hist-date { font-size: 13px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; }
.console-hist-badge { font-size: 10px; font-weight: 600; padding: 2px 8px; background: #f1f5f9; color: #475569; border-radius: 6px; white-space: nowrap; }
.console-hist-meta { font-size: 11.5px; color: #64748b; margin: 0; }
.console-hist-preview { font-size: 12px; color: #475569; margin: 5px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.console-hist-empty { padding: 40px 16px; text-align: center; color: #94a3b8; font-size: 13px; }
.console-hist-empty i { font-size: 30px; display: block; margin-bottom: 8px; }

.console-hist-detail { display: flex; flex-direction: column; height: 100%; }
.console-hist-detail-head {
    background: #fff; border-bottom: 1px solid #e2e8f0; padding: 11px 14px;
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 2;
}
.console-hist-back {
    display: flex; align-items: center; gap: 7px; font-size: 13px; color: #64748b;
    background: none; border: none; cursor: pointer; padding: 0;
}
.console-hist-back:hover { color: #0f172a; }
.console-hist-detail-title { font-size: 12px; font-weight: 600; margin: 0; font-family: 'IBM Plex Mono', monospace; text-align: right; }
.console-hist-detail-sub { font-size: 11px; color: #64748b; margin: 1px 0 0; text-align: right; }

/* Chat bubbles inside the History detail thread — mirrors portal.css's
   #chatArea .chats .chat rules (that selector doesn't match #histThread,
   which is why sent/received styling wasn't showing up here before). */
#histThread .chat { display: flex; justify-content: flex-start; margin: 6px 8px; }
#histThread .chat.chat-right { justify-content: flex-end; }
#histThread .chat .chat-body { display: flex; flex-direction: column; align-items: flex-start; }
#histThread .chat.chat-right .chat-body { align-items: flex-end; }
#histThread .chat .chat-body .chat-text { display: flex; margin: 0 0 4px; }
#histThread .chat .chat-body .chat-text p {
    padding: 8px 14px; background: #fff; border-radius: 12px 12px 12px 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.10); color: #374151; font-size: 13px;
    max-width: 420px; margin: 0; word-break: break-word;
}
#histThread .chat.chat-right .chat-body .chat-text p {
    background: #2563eb; color: #fff; border-radius: 12px 12px 0 12px;
}

/* ---- Empty state (no elevators configured) ---- */
.console-empty {
    max-width: 1600px; margin: 60px auto; padding: 0 24px; text-align: center; color: #64748b;
}
.console-empty i { font-size: 44px; color: #f59e0b; display: block; margin-bottom: 16px; }

/* ---- Configuration Refactoring App States ---- */
#appUnconfigured, #appConfiguring, #appError, #appReset {
    background-color: #0b0f19;
    color: #94a3b8;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0;
    padding: 0;
    max-width: 100%;
}

#appUnconfigured h3, #appConfiguring h3, #appError h3, #appReset h3 {
    color: #f8fafc;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 10px;
}

#appUnconfigured i { color: #64748b; }
#appConfiguring i { color: #3b82f6; }
#appError i { color: #ef4444; }
#appReset i { color: #10b981; }

#appActive {
    animation: fadeIn 0.4s ease-out;
}

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

