:root {
  --bg: #0f1420;
  --panel: #161d2e;
  --panel-2: #1d2740;
  --border: #2a3450;
  --text: #e8ecf7;
  --muted: #8a93ab;

  /* Brand: Gebeta Technology Trading plc */
  --brand: #8dc63f;
  --brand-dark: #6ea82f;
  --brand-darker: #588c22;
  --brand-soft: rgba(141, 198, 63, 0.16);

  --red: #e74c3c;
  --yellow: #f5a623;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --nav-height: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", Roboto, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden { display: none !important; }

button {
  font-family: inherit;
}

/* Press feedback on every pressable control */
.call-btn,
.ctrl-btn,
.status-btn,
.nav-item,
.dialpad button,
.dtmf-pad button,
.dialer-actions button {
  transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}
.call-btn:active,
.ctrl-btn:active,
.status-btn:active,
.nav-item:active,
.dialpad button:active,
.dtmf-pad button:active,
.dialer-actions button:active {
  transform: scale(0.97);
}

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 20px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 10px;
  object-fit: cover;
  background: var(--panel-2);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.agent-card {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex; align-items: center; gap: 12px;
}
.agent-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--brand); display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #10240a;
}
.agent-name { font-size: 13px; font-weight: 600; }
.agent-status { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-gray { background: var(--muted); }
.dot-green { background: var(--brand); box-shadow: 0 0 6px var(--brand); }
.dot-red { background: var(--red); box-shadow: 0 0 6px var(--red); }
.dot-yellow { background: var(--yellow); box-shadow: 0 0 6px var(--yellow); }

.status-toggle { display: flex; gap: 8px; }
.status-btn {
  flex: 1; padding: 8px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px;
}
.status-btn.active { background: var(--brand); color: #10240a; border-color: var(--brand); font-weight: 600; }

.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.nav-item {
  text-align: left; background: transparent; border: none; color: var(--muted);
  padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
@media (hover: hover) and (pointer: fine) {
  .nav-item:hover { background: var(--panel-2); }
}
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.sidebar-footer { margin-top: auto; font-size: 11px; color: var(--muted); word-break: break-all; }

/* Main */
.main { padding: 30px 40px; overflow-y: auto; }
.view h2 { font-weight: 600; }

.call-stage {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  min-height: 300px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  margin-bottom: 24px;
}

.stage-idle { text-align: center; color: var(--muted); }
.stage-idle-icon { font-size: 40px; margin-bottom: 10px; }
.stage-idle h2 { color: var(--text); margin: 0 0 6px; }

.stage-incoming, .stage-outgoing, .stage-active, .stage-idle {
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 220ms var(--ease-out), transform 220ms var(--ease-out);
}
.stage-incoming.stage-visible,
.stage-outgoing.stage-visible,
.stage-active.stage-visible,
.stage-idle.stage-visible {
  opacity: 1;
  transform: scale(1);
}

.stage-incoming, .stage-outgoing, .stage-active {
  display: flex; flex-direction: column; align-items: center; gap: 8px; position: relative;
}

.caller-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--panel-2); display: flex; align-items: center; justify-content: center;
  font-size: 34px; z-index: 1;
}
.caller-avatar.small { width: 60px; height: 60px; font-size: 24px; }

.pulse-ring {
  position: absolute; width: 84px; height: 84px; border-radius: 50%;
  border: 3px solid var(--brand); animation: pulse 1.6s var(--ease-out) infinite;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 0.9; }
  100% { transform: scale(2.2); opacity: 0; }
}

.caller-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 1px; }
.caller-number { font-size: 24px; font-weight: 700; word-break: break-word; text-align: center; }

.call-actions { display: flex; gap: 20px; margin-top: 10px; }
.call-actions.single { justify-content: center; }
.call-btn {
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 22px; color: white;
}
.call-btn.accept { background: var(--brand); color: #10240a; }
.call-btn.reject { background: var(--red); }

.call-timer { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }

.call-controls { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; justify-content: center; }
.ctrl-btn {
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 13px;
  min-height: 44px;
}
.ctrl-btn.active-state { background: var(--brand); border-color: var(--brand); color: #10240a; font-weight: 600; }
.ctrl-btn.hangup { background: var(--red); border-color: var(--red); }

.dtmf-pad {
  margin-top: 16px; display: grid; grid-template-columns: repeat(3, 50px); gap: 8px;
}
.dtmf-pad button {
  height: 44px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 15px; cursor: pointer;
}

.dialer {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px; max-width: 340px;
}
.dialer input {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 16px; margin-bottom: 14px; text-align: center;
}
.dialer input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.dialpad button {
  padding: 14px 0; border-radius: 10px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 16px; cursor: pointer;
  min-height: 48px;
}
.dialpad button:active { background: var(--brand); color: #10240a; }

.dialer-actions { display: flex; gap: 10px; }
.dialer-actions button {
  flex: 1; padding: 12px; border-radius: 10px; border: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer; min-height: 44px;
}
.dialer-actions button.primary { background: var(--brand); border-color: var(--brand); color: #10240a; font-weight: 600; }

/* SMS view */
.sms-notice {
  background: var(--brand-soft);
  border: 1px solid var(--brand-dark);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 20px;
  max-width: 720px;
}

.sms-layout {
  max-width: 480px;
  margin-bottom: 28px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
}

.field-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
  margin-top: 12px;
}
.field-label:first-child { margin-top: 0; }

.sms-compose input,
.sms-compose textarea {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.sms-compose input:focus,
.sms-compose textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.sms-counter { text-align: right; font-size: 11px; color: var(--muted); margin-top: 4px; }

button.full-width { width: 100%; margin-top: 14px; }
button.primary {
  background: var(--brand); border-color: var(--brand); color: #10240a;
  font-weight: 600; border-radius: 10px; padding: 12px; border: 1px solid var(--brand); cursor: pointer;
  min-height: 44px;
}
.sms-result { margin-top: 12px; font-size: 13px; min-height: 18px; }
.sms-result.ok { color: var(--brand); }
.sms-result.fail { color: var(--red); }

.sms-log-heading { margin-top: 0; }

.call-log-wrap { overflow-x: auto; }
.call-log { width: 100%; border-collapse: collapse; margin-top: 16px; min-width: 480px; }
.call-log th, .call-log td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.call-log th { color: var(--muted); font-weight: 500; }
.muted { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .call-btn, .ctrl-btn, .status-btn, .nav-item, .dialpad button, .dtmf-pad button, .dialer-actions button {
    transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  }
  .call-btn:active, .ctrl-btn:active, .status-btn:active, .nav-item:active,
  .dialpad button:active, .dtmf-pad button:active, .dialer-actions button:active {
    transform: none;
  }
  .stage-incoming, .stage-outgoing, .stage-active, .stage-idle {
    transform: none;
    transition: opacity 220ms ease;
  }
  .pulse-ring { animation: none; opacity: 0.5; }
}

/* ---------------------------------------------------------------------
   Mobile layout (phones / narrow tablets)
   Sidebar collapses to a compact top bar; navigation moves to a fixed
   bottom tab bar so it stays reachable with a thumb.
--------------------------------------------------------------------- */
@media (max-width: 860px) {
  .app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
  }

  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    gap: 12px;
  }

  .brand-text span { display: none; }

  .agent-card {
    flex: 1 1 auto;
    padding: 8px 12px;
    order: 2;
  }

  .status-toggle { order: 3; flex: 1 1 100%; }

  .sidebar-footer { display: none; }

  .nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    flex-direction: row;
    justify-content: space-around;
    height: var(--nav-height);
    margin-top: 0;
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 4px;
    z-index: 30;
  }
  .nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    font-size: 12px;
    border-radius: 10px;
  }

  .main {
    padding: 16px;
    padding-bottom: calc(var(--nav-height) + 24px);
  }

  .call-stage { min-height: 220px; padding: 20px; }
  .dialer { max-width: 100%; }
  .caller-number { font-size: 20px; }
}

@media (max-width: 420px) {
  .call-btn { width: 56px; height: 56px; font-size: 20px; }
  .call-actions { gap: 28px; }
  .ctrl-btn { padding: 10px 12px; font-size: 12px; }
}
