/* A OS — Main Stylesheet */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #13131a;
  --surface2: #1a1a24;
  --border: #2a2a3a;
  --text: #e8e8f0;
  --text-dim: #888;
  --accent: #6b6bff;
  --accent-hover: #5a5aee;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #fbbf24;
  --sidebar-width: 240px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  height: 100vh;
  overflow: hidden;
}

/* ── LAYOUT ───────────────────────────────────── */
#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-text { font-size: 20px; font-weight: 700; letter-spacing: 3px; }
.sidebar-logo .workspace { font-size: 11px; color: var(--text-dim); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; font-size: 14px; cursor: pointer;
  color: var(--text-dim); border-radius: 0;
  transition: all 0.15s; text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--surface2); color: var(--text); border-right: 2px solid var(--accent); }
.nav-item .icon { width: 18px; text-align: center; font-size: 15px; }
.nav-item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  margin-left: auto; flex-shrink: 0;
}
.dot.green { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot.red { background: var(--red); box-shadow: 0 0 5px var(--red); }
.dot.grey { background: var(--border); }
.dot.amber { background: var(--yellow); box-shadow: 0 0 5px var(--yellow); }

/* Sidebar ALTA Brand */
.sidebar-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sidebar-emblem {
  width: 34px; height: 34px;
  background: transparent;
  border-radius: 9px; flex-shrink: 0; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #fff;
  box-shadow: 0 0 12px rgba(107,107,255,0.3);
}
.sidebar-emblem img { width: 100%; height: 100%; object-fit: cover; border-radius: 9px; }
.sidebar-brand-name { font-size: 17px; font-weight: 800; letter-spacing: 3px; color: var(--text); line-height: 1; }
.sidebar-brand-sub { font-size: 9px; letter-spacing: 2px; color: var(--text-dim); text-transform: uppercase; margin-top: 2px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-dim);
}

/* Main content */
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: 
    linear-gradient(160deg, rgba(15,48,32,0.88) 0%, rgba(8,8,42,0.88) 50%, rgba(34,8,60,0.88) 100%),
    url('/img/alta-logo.png') center/420px no-repeat; }

/* Top bar */
#topbar {
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.topbar-status { font-size: 12px; color: var(--text-dim); }

/* Content area (tabs) */
#content { flex: 1; overflow: hidden; display: flex; }

/* ── DASHBOARD PANEL ──────────────────────────── */
#panel-dashboard {
  flex: 1; overflow-y: auto; padding: 24px;
  display: none; flex-direction: column; gap: 20px;
}
#panel-dashboard.active { display: flex; }

.section-title {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-dim); margin-bottom: 12px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.card {
  background: rgba(19,19,26,0.75);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}
.card-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.card-value { font-size: 22px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.card-status { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.up { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.down { background: var(--red); box-shadow: 0 0 6px var(--red); }
.status-dot.unknown { background: var(--border); }

.module-locked {
  opacity: 0.4;
  position: relative;
}
.module-locked::after {
  content: '🔑 Add API key in Settings';
  position: absolute; bottom: 12px; left: 16px;
  font-size: 11px; color: var(--text-dim);
}

/* ── CHAT PANEL ───────────────────────────────── */
#panel-chat {
  flex: 1; display: none; flex-direction: column; overflow: hidden;
}
#panel-chat.active { display: flex; }

#chat-messages {
  flex: 1; overflow-y: auto; padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}

.msg { display: flex; gap: 12px; max-width: 780px; }
.msg.user { flex-direction: row-reverse; margin-left: auto; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
  background: var(--surface2); border: 1px solid var(--border);
}
.msg.assistant .msg-avatar { background: #3a3a7a; color: #a0a0ff; }
.msg.user .msg-avatar { background: var(--surface2); color: var(--text-dim); }

.msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
  font-size: 14px; line-height: 1.6; max-width: 680px;
}
.msg.user .msg-bubble { background: var(--surface2); }

.msg-bubble pre {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 12px; margin: 8px 0;
  overflow-x: auto; font-size: 13px;
}
.msg-bubble code { font-family: 'Courier New', monospace; }

.chat-welcome {
  margin: auto; text-align: center; color: var(--text-dim);
  max-width: 400px;
}
.chat-welcome .big { font-size: 32px; margin-bottom: 12px; }
.chat-welcome p { font-size: 14px; line-height: 1.6; }

#chat-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.chat-input-row {
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 10px 14px;
}
#chat-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 14px; resize: none;
  max-height: 120px; min-height: 24px; line-height: 1.5;
  font-family: inherit;
}
#chat-send {
  background: var(--accent); border: none; border-radius: 8px;
  color: #fff; width: 34px; height: 34px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background 0.2s;
}
#chat-send:hover { background: var(--accent-hover); }
#chat-send:disabled { background: var(--border); cursor: not-allowed; }

.typing-indicator { display: flex; gap: 4px; align-items: center; padding: 4px 0; }
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim); animation: pulse 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; } }

/* ── SETTINGS PANEL ───────────────────────────── */
#panel-settings {
  flex: 1; overflow-y: auto; padding: 24px; display: none;
}
#panel-settings.active { display: block; }

.settings-section { max-width: 560px; margin-bottom: 32px; }
.settings-section h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

.setting-row { margin-bottom: 16px; }
.setting-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; }
.setting-row input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; padding: 10px 12px;
  outline: none; transition: border-color 0.2s;
}
.setting-row input:focus { border-color: var(--accent); }
.setting-status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 6px; }

.btn { padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: background 0.2s; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }

/* ── SCROLLBAR ────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── HAMBURGER BUTTON (hidden on desktop) ─────── */
#hamburger {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

/* ── SIDEBAR OVERLAY (mobile backdrop) ───────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 199;
}

/* ── MOBILE ───────────────────────────────────── */
@media (max-width: 640px) {
  #hamburger { display: flex; align-items: center; }

  #sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 200;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  #sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.8);
  }
  #sidebar-overlay.open { display: block; }

  .cards-grid { grid-template-columns: 1fr 1fr; }

  #topbar { padding: 0 12px; gap: 10px; }
  .topbar-title { font-size: 14px; }
}

/* ── COMPANY SWITCHER ─────────────────────────── */
#company-switcher {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 5px 8px;
  margin-top: 6px;
  outline: none;
  cursor: pointer;
}
#company-switcher:focus { border-color: var(--accent); }

/* ── NAV SECTION LABELS ───────────────────────── */
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #333;
  text-transform: uppercase;
  padding: 12px 20px 4px;
}

/* ── MODAL ────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h2 { font-size: 16px; margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── FORM ELEMENTS ────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; }
.form-row input,
.form-row select,
.form-row textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus { border-color: var(--accent); }
.form-row textarea { resize: vertical; min-height: 80px; }
.form-row select option { background: var(--surface2); }

.form-row-inline { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }

/* ── TABLE ────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(42,42,58,0.5);
  vertical-align: middle;
}
.data-table tr:hover td { background: var(--surface2); }

/* ── BADGES ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-green  { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-red    { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-yellow { background: rgba(251,191,36,0.15);  color: var(--yellow); }
.badge-blue   { background: rgba(99,102,241,0.15);  color: #818cf8; }
.badge-grey   { background: rgba(136,136,136,0.15); color: var(--text-dim); }

/* ── RECIPIENT CHIPS ──────────────────────────── */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; font-size: 12px;
}
.chip-remove {
  cursor: pointer; color: var(--text-dim); font-size: 14px; line-height: 1;
  margin-left: 2px;
}
.chip-remove:hover { color: var(--red); }

/* ── SEARCH BAR ───────────────────────────────── */
.search-bar {
  display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; align-items: center;
}
.search-bar input {
  flex: 1; min-width: 180px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
  padding: 8px 12px; outline: none;
}
.search-bar input:focus { border-color: var(--accent); }
.search-bar select {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px;
  padding: 8px 10px; outline: none; cursor: pointer;
}
