/* ============================================================
   Fibi CPaaS — Main Stylesheet
   Theme: Dark #0c0d12 · Pink #ed0d92 · Font: Poppins
   ============================================================ */

/* ── Google Fonts fallback embed ─────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:        #ed0d92;
  --brand-dark:   #c4077a;
  --brand-light:  #fce7f3;
  --brand-glow:   rgba(237, 13, 146, 0.25);
  --brand-subtle: rgba(237, 13, 146, 0.10);

  /* Semantic */
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #3b82f6;

  /* App chrome — dark */
  --bg:           #0c0d12;
  --bg-2:         #12131a;
  --surface:      #181920;
  --surface-2:    #1e1f28;
  --surface-3:    #25263000;
  --border:       rgba(255,255,255,0.07);
  --border-2:     rgba(255,255,255,0.12);

  /* Text */
  --text:         #f0f1f5;
  --text-2:       #9496a8;
  --text-3:       #505265;
  --text-inv:     #ffffff;

  /* Layout */
  --sidebar-w:    240px;
  --header-h:     56px;
  --radius:       8px;
  --radius-lg:    12px;
  --radius-xl:    16px;

  /* Shadows */
  --shadow-sm:    0 1px 3px rgba(0,0,0,0.4);
  --shadow:       0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:    0 12px 36px rgba(0,0,0,0.6);
  --shadow-brand: 0 4px 20px rgba(237,13,146,0.30);

  /* Font */
  --font:         'Poppins', system-ui, -apple-system, sans-serif;
  --mono:         'JetBrains Mono', 'Fira Code', monospace;

  --transition:   0.18s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, textarea, select {
  font: inherit;
  outline: none;
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: .5rem .75rem;
  background: var(--surface-2);
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-font-smoothing: antialiased;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; min-height: 80px; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239496a8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; padding-right: 2rem; }

/* ── App Layout ─────────────────────────────────────────────── */
#app { display: none; height: 100vh; flex-direction: column; background: var(--bg); }
#app.visible { display: flex; }

/* ── Header ──────────────────────────────────────────────────── */
.app-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: .75rem;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 1px 0 var(--border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: .55rem;
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  min-width: 200px;
  letter-spacing: -.01em;
}
.header-logo .logo-icon {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--brand), #9333ea);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-brand);
}

.header-search {
  flex: 1;
  max-width: 360px;
  position: relative;
}
.header-search input {
  padding-left: 2.2rem;
  font-size: .82rem;
  height: 34px;
  background: var(--bg-2);
  border-color: var(--border);
  border-radius: 20px;
}
.header-search input:focus { border-color: var(--brand); border-radius: 20px; }
.header-search .search-icon {
  position: absolute; left: .75rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

.header-actions {
  margin-left: auto;
  display: flex; align-items: center; gap: .2rem;
}

.header-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  position: relative;
  transition: background var(--transition), color var(--transition);
}
.header-btn:hover { background: var(--surface-2); color: var(--text); }

.badge {
  position: absolute;
  top: 3px; right: 3px;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  min-width: 15px; height: 15px;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
  box-shadow: 0 0 0 2px var(--surface);
}

/* User menu */
.user-menu-wrap { position: relative; }
.user-avatar-btn {
  display: flex; align-items: center; gap: .5rem;
  padding: .3rem .5rem;
  border-radius: var(--radius);
  color: var(--text);
  transition: background var(--transition);
  margin-left: .2rem;
}
.user-avatar-btn:hover { background: var(--surface-2); }

.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #9333ea);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700;
  flex-shrink: 0;
}
.avatar.sm { width: 26px; height: 26px; font-size: .65rem; }
.avatar.lg { width: 40px; height: 40px; font-size: 1rem; }
.avatar.xl { width: 60px; height: 60px; font-size: 1.4rem; }

.user-name { font-size: .82rem; font-weight: 600; color: var(--text); }
.user-role { font-size: .7rem; color: var(--text-3); }

.dropdown-menu {
  position: absolute;
  right: 0; top: calc(100% + 6px);
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 210px;
  z-index: 1000;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; animation: dd-in .15s ease; }
@keyframes dd-in {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-header {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.dropdown-header .name  { font-weight: 600; font-size: .875rem; color: var(--text); }
.dropdown-header .email { font-size: .72rem; color: var(--text-3); margin-top: .1rem; }

.dropdown-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1rem;
  font-size: .82rem;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  width: 100%; text-align: left;
}
.dropdown-item:hover { background: var(--surface); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(239,68,68,.08); }
.dropdown-divider { border: none; border-top: 1px solid var(--border); margin: .25rem 0; }

/* Status dot */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  flex-shrink: 0;
}
.status-dot.online  { background: var(--success); }
.status-dot.busy    { background: var(--danger); }
.status-dot.away    { background: var(--warning); }
.status-dot.offline { background: var(--text-3); }

/* ── App Body ─────────────────────────────────────────────── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-section { padding: .875rem .625rem .5rem; }
.sidebar-section-title {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-3);
  padding: 0 .5rem;
  margin-bottom: .4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .75rem;
  border-radius: var(--radius);
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  position: relative;
  width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--brand-subtle);
  color: var(--brand);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 25%; bottom: 25%;
  width: 3px;
  background: var(--brand);
  border-radius: 0 2px 2px 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  min-width: 17px; height: 17px;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.channel-nav {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .75rem;
  border-radius: var(--radius);
  font-size: .8rem; font-weight: 500;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  cursor: pointer; width: 100%; text-align: left;
}
.channel-nav:hover { background: var(--surface-2); color: var(--text); }
.channel-nav.active { background: var(--brand-subtle); color: var(--brand); }
.channel-hash { color: var(--text-3); font-size: .9rem; }
.channel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-unread {
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  min-width: 16px; height: 16px;
  font-size: .6rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: none;
}
.main-content.active { display: block; }
.main-content.chat-layout {
  display: none;
  padding: 0;
  flex-direction: row;
  overflow: hidden;
}
.main-content.chat-layout.active { display: flex; }

/* ── Page Header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-title   { font-size: 1.3rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.page-subtitle { color: var(--text-2); font-size: .82rem; margin-top: .2rem; }
.page-actions  { margin-left: auto; display: flex; gap: .5rem; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .48rem 1rem;
  border-radius: var(--radius);
  font-size: .82rem; font-weight: 600;
  transition: all var(--transition);
  white-space: nowrap; cursor: pointer;
  font-family: var(--font);
  letter-spacing: -.01em;
}
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #9333ea);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.btn-primary:hover { opacity: .88; transform: translateY(-1px); box-shadow: 0 6px 24px var(--brand-glow); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border-2);
}
.btn-secondary:hover { background: var(--surface-3); color: var(--text); border-color: var(--brand); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .88; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }
.btn-ghost    { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm  { padding: .3rem .7rem; font-size: .75rem; }
.btn-lg  { padding: .65rem 1.4rem; font-size: .9rem; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; }
.btn-icon.active { background: var(--brand-subtle); color: var(--brand); }

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-body   { padding: 1.25rem; }
.card-header {
  padding: .875rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface);
}
.card-title  { font-size: .9rem; font-weight: 600; color: var(--text); }
.card-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border); }

/* ── Stats Grid ───────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  display: flex; flex-direction: column; gap: .4rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.stat-card:hover { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand-glow); }
.stat-label { font-size: .72rem; color: var(--text-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; color: var(--text); letter-spacing: -.03em; }
.stat-change { font-size: .72rem; color: var(--text-3); }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .2rem;
  font-size: 1rem;
}
.stat-icon.pink   { background: rgba(237,13,146,.12); color: var(--brand); }
.stat-icon.purple { background: rgba(147,51,234,.12);  color: #a855f7; }
.stat-icon.green  { background: rgba(34,197,94,.10);   color: var(--success); }
.stat-icon.blue   { background: rgba(59,130,246,.10);  color: var(--info); }
.stat-icon.amber  { background: rgba(245,158,11,.10);  color: var(--warning); }
.stat-icon.red    { background: rgba(239,68,68,.10);   color: var(--danger); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
thead th {
  padding: .6rem 1rem;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  white-space: nowrap;
}
tbody td {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-2); color: var(--text); }

/* ── Chips ────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .68rem; font-weight: 700;
  white-space: nowrap; letter-spacing: .02em;
}
.chip-green  { background: rgba(34,197,94,.12);  color: #4ade80; border: 1px solid rgba(34,197,94,.2); }
.chip-red    { background: rgba(239,68,68,.12);  color: #f87171; border: 1px solid rgba(239,68,68,.2); }
.chip-yellow { background: rgba(245,158,11,.12); color: #fbbf24; border: 1px solid rgba(245,158,11,.2); }
.chip-blue   { background: rgba(59,130,246,.12); color: #60a5fa; border: 1px solid rgba(59,130,246,.2); }
.chip-purple { background: rgba(147,51,234,.12); color: #c084fc; border: 1px solid rgba(147,51,234,.2); }
.chip-pink   { background: rgba(237,13,146,.12); color: #f472b6; border: 1px solid rgba(237,13,146,.2); }
.chip-gray   { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group   { margin-bottom: 1rem; }
.form-label   { display: block; font-size: .75rem; font-weight: 600; margin-bottom: .4rem; color: var(--text-2); letter-spacing: .01em; }
.form-hint    { font-size: .7rem; color: var(--text-3); margin-top: .3rem; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.input-group  { display: flex; }
.input-group input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group .input-addon {
  display: flex; align-items: center; padding: 0 .75rem;
  background: var(--bg-2);
  border: 1px solid var(--border-2); border-left: none;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: .8rem; color: var(--text-2); white-space: nowrap;
}
.input-group .btn { border-radius: 0 var(--radius) var(--radius) 0; }

/* ── Modals ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center; justify-content: center;
  z-index: 2000;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 500px;
  max-height: 90vh; overflow-y: auto;
  animation: modal-in .2s cubic-bezier(.16,1,.3,1);
}
.modal-lg { max-width: 700px; }
.modal-header {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.modal-title { font-size: 1rem; font-weight: 700; flex: 1; color: var(--text); }
.modal-close {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px; color: var(--text-3);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: var(--surface-2); color: var(--text); }
.modal-body   { padding: 1.4rem; }
.modal-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .75rem; justify-content: flex-end;
  background: var(--bg-2);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: .82rem;
  min-width: 250px; max-width: 360px;
  pointer-events: all;
  animation: toast-in .25s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info    { border-left: 3px solid var(--brand); }
.toast-icon    { flex-shrink: 0; }
.toast-text    { flex: 1; }
@keyframes toast-in {
  from { transform: translateX(50px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Tabs ─────────────────────────────────────────────────── */
.tabs        { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.tab-btn     { padding: .6rem 1rem; font-size: .82rem; font-weight: 600; color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all var(--transition); cursor: pointer; }
.tab-btn:hover  { color: var(--text-2); }
.tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-pane       { display: none; }
.tab-pane.active { display: block; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 3.5rem 2rem; text-align: center; color: var(--text-3);
}
.empty-state svg { margin-bottom: 1rem; opacity: .3; }
.empty-state h3  { font-size: 1rem; font-weight: 600; margin-bottom: .4rem; color: var(--text-2); }
.empty-state p   { font-size: .82rem; max-width: 280px; line-height: 1.5; }

/* ── Loading ──────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
.loading-row td { padding: 2rem; text-align: center; color: var(--text-3); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Softphone Widget ─────────────────────────────────────── */
.softphone-widget {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 320px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-2);
  z-index: 1500;
  display: none; flex-direction: column;
  overflow: hidden;
  animation: modal-in .2s ease;
}
.softphone-widget.open { display: flex; }
.sw-header {
  background: linear-gradient(135deg, var(--brand), #9333ea);
  color: #fff;
  padding: .7rem 1rem;
  display: flex; align-items: center; gap: .6rem;
}
.sw-title   { flex: 1; font-weight: 600; font-size: .85rem; }
.sw-header-btn { color: rgba(255,255,255,.7); transition: color var(--transition); font-size: .85rem; }
.sw-header-btn:hover { color: #fff; }
.sw-display {
  padding: 1rem;
  background: var(--bg);
  text-align: center;
  min-height: 72px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.sw-number   { font-size: 1.4rem; font-weight: 700; font-family: var(--mono); letter-spacing: .04em; min-height: 1.8rem; color: var(--text); }
.sw-status   { font-size: .72rem; color: var(--text-3); margin-top: .2rem; }
.sw-keypad   { display: grid; grid-template-columns: repeat(3,1fr); gap: 1px; background: var(--border); }
.sw-key {
  background: var(--surface);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: .7rem;
  font-size: 1.1rem; font-weight: 700;
  transition: background var(--transition);
  cursor: pointer; color: var(--text);
}
.sw-key:hover  { background: var(--surface-2); }
.sw-key:active { background: var(--brand-subtle); }
.sw-key sub    { font-size: .55rem; font-weight: 400; color: var(--text-3); letter-spacing: .12em; }
.sw-actions {
  display: flex; justify-content: center; gap: .75rem;
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.sw-action-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.sw-action-btn.call { background: linear-gradient(135deg, var(--brand), #9333ea); color: #fff; box-shadow: var(--shadow-brand); }
.sw-action-btn.end  { background: var(--danger); color: #fff; }
.sw-action-btn.mute { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border-2); }
.sw-action-btn:hover { transform: scale(1.08); }

/* ── Incoming Call Popup ──────────────────────────────────── */
.incoming-call-popup {
  position: fixed;
  top: calc(var(--header-h) + 1rem); right: 1rem;
  width: 290px;
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border-2);
  z-index: 1800; overflow: hidden; display: none;
}
.incoming-call-popup.show { display: block; animation: modal-in .25s ease; }
.incoming-call-header {
  background: linear-gradient(135deg, var(--brand), #9333ea);
  color: #fff; padding: .65rem 1rem;
  font-size: .75rem; font-weight: 600;
  display: flex; align-items: center; gap: .5rem;
}
.incoming-call-body { padding: 1rem; }
.incoming-number { font-size: 1.1rem; font-weight: 700; margin-bottom: .2rem; color: var(--text); }
.incoming-type   { font-size: .72rem; color: var(--text-3); margin-bottom: .9rem; }
.incoming-actions { display: flex; gap: .5rem; }

/* ── SMS Layout ───────────────────────────────────────────── */
.sms-layout       { display: flex; height: 100%; }
.sms-sidebar      { width: 290px; border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; background: var(--surface); }
.sms-sidebar-header { padding: .875rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .5rem; background: var(--bg-2); }
.sms-list         { flex: 1; overflow-y: auto; }
.conversation-item {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background var(--transition);
}
.conversation-item:hover { background: var(--surface-2); }
.conversation-item.active { background: var(--brand-subtle); }
.conversation-item.unread .conv-number { color: var(--text); font-weight: 600; }
.conv-info    { flex: 1; min-width: 0; }
.conv-number  { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.conv-preview { font-size: .72rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: .15rem; }
.conv-time    { font-size: .65rem; color: var(--text-3); flex-shrink: 0; }
.sms-main     { flex: 1; display: flex; flex-direction: column; background: var(--bg); }
.sms-thread-header { padding: .8rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: .75rem; background: var(--surface); }
.sms-thread   { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.sms-bubble {
  max-width: 68%;
  padding: .55rem .85rem;
  border-radius: 14px;
  font-size: .82rem; line-height: 1.45; word-break: break-word;
}
.sms-bubble.in  { align-self: flex-start; background: var(--surface-2); border-radius: 14px 14px 14px 3px; color: var(--text); }
.sms-bubble.out { align-self: flex-end; background: linear-gradient(135deg, var(--brand), #9333ea); color: #fff; border-radius: 14px 14px 3px 14px; }
.sms-meta { font-size: .65rem; color: var(--text-3); margin-top: .2rem; }
.sms-compose {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex; gap: .5rem; align-items: flex-end;
  background: var(--surface);
}
.sms-compose textarea { min-height: 38px; max-height: 110px; resize: none; }

/* ── Chat Layout ──────────────────────────────────────────── */
.chat-sidebar {
  width: 240px;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  background: var(--surface); flex-shrink: 0;
}
.chat-sidebar-header {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: .9rem; color: var(--text);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg-2);
}
.chat-channel-list { flex: 1; overflow-y: auto; padding: .5rem; }
.chat-main { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }
.chat-header {
  padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem;
  background: var(--surface);
}
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .2rem; }
.chat-message {
  display: flex; gap: .65rem;
  padding: .3rem .5rem;
  border-radius: var(--radius);
  transition: background var(--transition);
}
.chat-message:hover { background: var(--surface-2); }
.chat-message-content { flex: 1; min-width: 0; }
.chat-message-header { display: flex; align-items: baseline; gap: .5rem; margin-bottom: .1rem; }
.chat-sender { font-weight: 600; font-size: .82rem; color: var(--text); }
.chat-time   { font-size: .65rem; color: var(--text-3); }
.chat-body   { font-size: .82rem; line-height: 1.5; word-break: break-word; color: var(--text-2); }
.chat-input-area { padding: .65rem .9rem; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input-wrap {
  display: flex; align-items: flex-end; gap: .5rem;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: .45rem .75rem;
}
.chat-input-wrap:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-glow); }
.chat-input-wrap textarea { border: none; background: none; padding: 0; min-height: 22px; max-height: 130px; resize: none; font-size: .82rem; box-shadow: none; color: var(--text); }
.chat-input-wrap textarea::placeholder { color: var(--text-3); }
.chat-input-wrap textarea:focus { box-shadow: none; }
.chat-input-actions { display: flex; gap: .25rem; }
.chat-date-divider {
  text-align: center; font-size: .68rem; color: var(--text-3);
  position: relative; margin: .75rem 0;
}
.chat-date-divider::before, .chat-date-divider::after {
  content: ''; position: absolute;
  top: 50%; width: calc(50% - 3.5rem); height: 1px;
  background: var(--border);
}
.chat-date-divider::before { left: 0; }
.chat-date-divider::after  { right: 0; }
.typing-indicator { font-size: .72rem; color: var(--text-3); padding: 0 .5rem .4rem; min-height: 18px; }

/* ── Numbers / IVR ────────────────────────────────────────── */
.number-card {
  display: flex; align-items: center; gap: .9rem;
  padding: .9rem 1.1rem;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.number-card:hover { background: var(--surface-2); }
.number-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--brand-subtle);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.number-info    { flex: 1; }
.number-e164    { font-weight: 700; font-size: .9rem; color: var(--text); }
.number-meta    { font-size: .7rem; color: var(--text-3); margin-top: .15rem; }
.number-caps    { display: flex; gap: .3rem; margin-top: .35rem; }
.number-actions { display: flex; gap: .35rem; }

.ivr-option-row {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem;
  background: var(--bg-2);
  border-radius: var(--radius);
  margin-bottom: .5rem;
}
.ivr-option-key {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #9333ea);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .9rem; flex-shrink: 0;
}

/* ── Admin ────────────────────────────────────────────────── */
.admin-nav    { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.user-row     { display: flex; align-items: center; gap: .7rem; }
.user-row .user-info  { flex: 1; }
.user-row .user-email { font-size: .7rem; color: var(--text-3); }

/* ── Profile ──────────────────────────────────────────────── */
.profile-header {
  display: flex; align-items: center; gap: 1.25rem;
  padding: 1.25rem;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.profile-info h2 { font-size: 1.2rem; font-weight: 700; color: var(--text); }

/* ── Dashboard ────────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.1rem; }
.activity-item {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .6rem;
  border-radius: var(--radius);
  font-size: .8rem;
}
.activity-icon {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.activity-text { flex: 1; color: var(--text-2); }
.activity-time { font-size: .65rem; color: var(--text-3); margin-top: .1rem; }

/* ── Scrollbars ───────────────────────────────────────────── */
::-webkit-scrollbar           { width: 5px; height: 5px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--border-2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Utilities ────────────────────────────────────────────── */
.flex           { display: flex; }
.flex-1         { flex: 1; }
.items-center   { align-items: center; }
.justify-between{ justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.text-sm   { font-size: .82rem; }
.text-xs   { font-size: .7rem; }
.text-muted{ color: var(--text-3); }
.text-2    { color: var(--text-2); }
.text-danger { color: var(--danger); }
.text-success{ color: var(--success); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--mono); }
.mt-1{margin-top:.25rem} .mt-2{margin-top:.5rem} .mt-3{margin-top:.75rem} .mt-4{margin-top:1rem}
.mb-1{margin-bottom:.25rem} .mb-2{margin-bottom:.5rem} .mb-3{margin-bottom:.75rem} .mb-4{margin-bottom:1rem}
.p-4 { padding: 1rem; }
.hidden  { display: none !important; }
.truncate{ overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full  { width: 100%; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3  { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .softphone-widget { width: calc(100vw - 2rem); right: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
