/* ==========================================================
   Centrala Telefonica — sistem vizual
   Principiu: suprafata desaturata, culoarea rezervata STARII.
   Albastru = actiune. Cald = stare. Nimic altceva nu e saturat.
   ========================================================== */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* structura */
  --ink:        #0F1419;
  --ink-2:      #2B333C;
  --ink-3:      #5A6672;
  --ink-4:      #8B97A3;
  --paper:      #E9EBEE;
  --panel:      #FFFFFF;
  --panel-2:    #F4F5F7;
  --line:       #D2D7DD;
  --line-soft:  #E3E7EB;

  /* stare — singurele culori saturate */
  --free:       #0E7C4A;
  --free-bg:    #E3F3EA;
  --busy:       #B01F26;
  --busy-bg:    #FBE7E8;
  --hold:       #B36A00;
  --hold-bg:    #FCF0DC;
  --offline:    #8B97A3;
  --offline-bg: #EDEFF2;

  /* actiune */
  --act:        #1B4FD8;
  --act-hover:  #1740B0;
  --act-soft:   #E7EDFC;

  --radius:     6px;
  --radius-sm:  4px;
  --shadow:     0 1px 2px rgba(15,20,25,.06), 0 4px 12px rgba(15,20,25,.05);
  --shadow-lg:  0 8px 32px rgba(15,20,25,.16);

  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'Archivo', -apple-system, system-ui, sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* toate cifrele sunt tabulare si mono — numere, extensii, cronometre */
.mono, .num, td.num, input[type="tel"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}

/* ---------- structura paginii ---------- */

.topbar {
  background: var(--ink);
  color: #fff;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .brand {
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -.02em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 9px;
}
.topbar .brand::before {
  content: '';
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--free);
  box-shadow: 0 0 0 3px rgba(14,124,74,.28);
}
.topbar .tenant {
  font-size: 12px;
  color: rgba(255,255,255,.62);
  padding-left: 20px;
  border-left: 1px solid rgba(255,255,255,.16);
}
.topbar nav { display: flex; gap: 2px; margin-left: auto; }
.topbar nav a {
  color: rgba(255,255,255,.68);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
}
.topbar nav a:hover { color: #fff; background: rgba(255,255,255,.09); }
.topbar nav a.on { color: #fff; background: rgba(255,255,255,.16); }

.wrap { max-width: 1560px; margin: 0 auto; padding: 18px; }
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: minmax(0,1.6fr) minmax(340px,1fr); }

/* ---------- panouri ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel > header {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
}
.panel > header h2 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-3);
}
.panel > header .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.panel .body { padding: 14px; }
.panel .body.flush { padding: 0; }

/* ---------- SEMNATURA: campul de lampi ---------- */
/* Grila de indicatori per operator, ca pe tabloul unei centrale clasice. */

.lampfield {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 14px;
  background: var(--ink);
  border-radius: var(--radius);
  border: 1px solid #000;
}
.lamp {
  position: relative;
  min-width: 82px;
  padding: 7px 9px 8px;
  border-radius: var(--radius-sm);
  background: #1A2129;
  border: 1px solid #2B333C;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background .15s;
}
.lamp .ext {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -.02em;
}
.lamp .who {
  font-size: 10px;
  color: rgba(255,255,255,.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}
.lamp::before {
  content: '';
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--offline);
}
.lamp[data-s="available"] { background: #0D2419; border-color: #175236; }
.lamp[data-s="available"]::before { background: #22C97B; box-shadow: 0 0 7px #22C97B; }
.lamp[data-s="on_call"]   { background: #2A0F11; border-color: #5C1E22; }
.lamp[data-s="on_call"]::before { background: #F2555E; box-shadow: 0 0 7px #F2555E; animation: pulse 1.1s ease-in-out infinite; }
.lamp[data-s="paused"]    { background: #2A1D08; border-color: #5C4213; }
.lamp[data-s="paused"]::before { background: #FFB020; box-shadow: 0 0 7px #FFB020; }
.lamp[data-s="ringing"]   { background: #2A1D08; border-color: #8A6416; }
.lamp[data-s="ringing"]::before { background: #FFD24A; box-shadow: 0 0 9px #FFD24A; animation: pulse .5s ease-in-out infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .28; } }
@media (prefers-reduced-motion: reduce) {
  .lamp::before { animation: none !important; }
  * { transition: none !important; }
}

.lampfield .legend {
  margin-left: auto;
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 10px;
  color: rgba(255,255,255,.44);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.lampfield .legend i {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

/* ---------- indicatori de stare inline ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 100px;
  white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.free    { color: var(--free);    background: var(--free-bg); }
.badge.busy    { color: var(--busy);    background: var(--busy-bg); }
.badge.hold    { color: var(--hold);    background: var(--hold-bg); }
.badge.off     { color: var(--ink-3);   background: var(--offline-bg); }
.badge.act     { color: var(--act);     background: var(--act-soft); }
.badge.plain   { color: var(--ink-3);   background: var(--panel-2); }
.badge.plain::before { display: none; }

/* ---------- statistici ---------- */

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 13px 15px;
}
.stat .k {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--ink-4);
  margin-bottom: 5px;
}
.stat .v {
  font-family: var(--mono);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -.03em;
  line-height: 1.1;
}
.stat .sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.stat.is-busy .v { color: var(--busy); }
.stat.is-free .v { color: var(--free); }

/* ---------- tabele ---------- */

table { width: 100%; border-collapse: collapse; }
thead th {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--ink-4);
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  position: sticky;
  top: 0;
  z-index: 2;
}
tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
tbody tr:hover { background: #FAFBFC; }
tbody tr.flagged { background: var(--busy-bg); }
tbody tr.flagged:hover { background: #F8DDDE; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.scroll { max-height: 460px; overflow: auto; }
.empty {
  padding: 34px 20px;
  text-align: center;
  color: var(--ink-3);
  font-size: 13px;
}
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; font-size: 14px; }

/* ---------- controale ---------- */

button, .btn {
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .12s, border-color .12s;
}
button:hover, .btn:hover { background: var(--panel-2); border-color: var(--ink-4); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--act);
  outline-offset: 1px;
}
button:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--act); border-color: var(--act); color: #fff; }
.btn-primary:hover { background: var(--act-hover); border-color: var(--act-hover); }
.btn-danger { background: var(--busy); border-color: var(--busy); color: #fff; }
.btn-danger:hover { background: #8F181E; border-color: #8F181E; }
.btn-ok { background: var(--free); border-color: var(--free); color: #fff; }
.btn-ok:hover { background: #0A6039; border-color: #0A6039; }
.btn-sm { font-size: 11.5px; padding: 4px 9px; }
.btn-lg { font-size: 14px; padding: 11px 20px; }
.btn-block { width: 100%; justify-content: center; }

input, select, textarea {
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  width: 100%;
}
input:disabled { background: var(--panel-2); color: var(--ink-3); }
label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-3);
  margin-bottom: 5px;
}
.field { margin-bottom: 13px; }
.field .hint { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.row { display: flex; gap: 9px; align-items: center; }
.row > * { flex: 1; }
.row > .fixed { flex: 0 0 auto; }

/* ---------- apel activ ---------- */

.call-live {
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px;
}
.call-live .from {
  font-family: var(--mono);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.03em;
}
.call-live .meta { font-size: 12.5px; color: rgba(255,255,255,.62); margin-top: 3px; }
.call-live .timer {
  font-family: var(--mono);
  font-size: 15px;
  color: #22C97B;
  margin-top: 9px;
  font-variant-numeric: tabular-nums;
}
.call-live .actions { display: flex; gap: 8px; margin-top: 15px; }

.ringing-banner {
  background: var(--hold-bg);
  border: 1px solid var(--hold);
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  animation: slidein .25s ease;
}
@keyframes slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ---------- dialpad ---------- */

.dialpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.dialpad button {
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 500;
  padding: 12px 0;
  justify-content: center;
}

/* ---------- fisa client ---------- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; align-self: center; }
.kv dd { font-weight: 500; }

.rate { display: flex; align-items: center; gap: 8px; }
.rate .bar { flex: 1; height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; max-width: 90px; }
.rate .bar i { display: block; height: 100%; background: var(--free); }
.rate.low .bar i { background: var(--busy); }
.rate.mid .bar i { background: var(--hold); }

/* ---------- notificari ---------- */

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--ink);
  color: #fff;
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  max-width: 380px;
  animation: slidein .2s ease;
}
.toast.bad { background: var(--busy); }
.toast.good { background: var(--free); }

/* ---------- modal ---------- */

.backdrop {
  position: fixed; inset: 0;
  background: rgba(15,20,25,.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 150; padding: 20px;
}
.modal {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow: auto;
}
.modal header { padding: 15px 18px; border-bottom: 1px solid var(--line-soft); }
.modal header h3 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.modal .body { padding: 18px; }
.modal footer { padding: 13px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; justify-content: flex-end; background: var(--panel-2); }

/* ---------- login ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 20px;
}
.login-card { width: 100%; max-width: 380px; }
.login-card .mark {
  font-weight: 800;
  font-size: 19px;
  color: #fff;
  letter-spacing: -.02em;
  text-transform: uppercase;
  margin-bottom: 4px;
  display: flex; align-items: center; gap: 10px;
}
.login-card .mark::before {
  content: ''; width: 11px; height: 11px; border-radius: 50%;
  background: #22C97B; box-shadow: 0 0 0 4px rgba(34,201,123,.2);
}
.login-card .sub { color: rgba(255,255,255,.5); font-size: 13px; margin-bottom: 22px; padding-left: 21px; }
.login-card form { background: var(--panel); border-radius: var(--radius); padding: 20px; }

/* ---------- utilitare ---------- */

.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.muted { color: var(--ink-3); }
.small { font-size: 11.5px; }
.strong { font-weight: 700; }
.hide { display: none !important; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.tag {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
}
.copy { cursor: pointer; }
.copy:hover { background: var(--act-soft); border-color: var(--act); color: var(--act); }

@media (max-width: 1100px) {
  .g-main, .g-3, .g-4 { grid-template-columns: 1fr; }
  .g-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  /* pe ecran ingust tabelele se deruleaza lateral, nu se comprima ilizibil */
  .scroll, .panel .body.flush { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .scroll table, .panel .body.flush table { min-width: 660px; }
  thead th { position: static; }
}
@media (max-width: 640px) {
  .wrap { padding: 12px; }
  .g-2, .g-4 { grid-template-columns: 1fr; }
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 12px; gap: 10px; }
  .topbar nav { width: 100%; overflow-x: auto; }
  .topbar .tenant { padding-left: 0; border-left: none; }
}
