/* ═══════════════════════════════════════════
   CallDesk CRM — Main Stylesheet
   File: css/style.css
═══════════════════════════════════════════ */

:root {
  --bg:      #0d0f14;
  --surface: #161b24;
  --surface2:#1e2535;
  --surface3:#252d3d;
  --border:  #2a3347;
  --accent:  #4f8ef7;
  --accent2: #7c5af5;
  --green:   #22c981;
  --yellow:  #f5c842;
  --red:     #f25c5c;
  --text:    #e8edf5;
  --text2:   #8a97b0;
  --text3:   #4a5568;
}

/* ── RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}
h1,h2,h3,h4 { font-family: 'Syne', sans-serif; }
a { text-decoration: none; }

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

/* ══════════════════════════════════════════
   LOADING SCREEN
══════════════════════════════════════════ */
#loadingScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  color: var(--text2);
}
#loadingScreen .spinner { width: 36px; height: 36px; border-width: 3px; }

/* ══════════════════════════════════════════
   LOGIN
══════════════════════════════════════════ */
#loginScreen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(79,142,247,.13) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(124,90,245,.10) 0%, transparent 60%),
    var(--bg);
}
#loginScreen.visible { display: flex; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.4), 0 0 60px rgba(79,142,247,.06);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo h1 { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.login-logo h1 span { color: var(--accent); }
.login-logo p { color: var(--text2); font-size: 13px; margin-top: 4px; }
.login-hint { text-align: center; color: var(--text2); font-size: 12px; margin-top: 16px; }
.login-hint strong { color: var(--text); }

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.fg { margin-bottom: 18px; }
.fg label {
  display: block;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 8px;
}
.fg input,
.fg select,
.fg textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  transition: border-color .2s;
}
.fg input:focus,
.fg select:focus,
.fg textarea:focus { outline: none; border-color: var(--accent); }
.fg textarea { resize: vertical; min-height: 80px; padding: 10px 14px; font-size: 13px; }
.fg input:disabled { opacity: .5; cursor: not-allowed; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .15s;
  font-family: 'DM Sans', sans-serif;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none !important; }
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: #6b9ef9; transform: translateY(-1px); }
.btn-secondary{ background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover{ background: var(--surface3); }
.btn-danger   { background: rgba(242,92,92,.15); color: var(--red); border: 1px solid rgba(242,92,92,.3); }
.btn-danger:hover   { background: rgba(242,92,92,.25); }
.btn-success  { background: rgba(34,201,129,.15); color: var(--green); border: 1px solid rgba(34,201,129,.3); }
.btn-success:hover  { background: rgba(34,201,129,.25); }
.btn-wa       { background: rgba(37,211,102,.15); color: #25d366; border: 1px solid rgba(37,211,102,.3); }
.btn-wa:hover       { background: rgba(37,211,102,.25); }
.btn-sm  { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 14px; font-size: 15px; }

/* ══════════════════════════════════════════
   APP LAYOUT
══════════════════════════════════════════ */
#app { display: none; }
#app.visible { display: block; }
.app-layout { display: flex; min-height: 100vh; }

/* ══════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════ */
.sidebar {
  width: 230px;
  min-height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}
.sb-logo { padding: 22px 20px 14px; border-bottom: 1px solid var(--border); }
.sb-logo h2 { font-size: 20px; font-weight: 800; }
.sb-logo h2 span { color: var(--accent); }
.sb-logo p { font-size: 11px; color: var(--text2); margin-top: 2px; }
.sb-user {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sb-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sb-uname { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-urole { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; }
.sb-nav { padding: 12px; flex: 1; overflow-y: auto; }
.sb-section { margin-bottom: 20px; }
.sb-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text3); padding: 0 8px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px; cursor: pointer;
  transition: all .15s; color: var(--text2); font-size: 13px; font-weight: 500; margin-bottom: 2px;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(79,142,247,.15); color: var(--accent); }
.nav-item .ni { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; display: none;
}
.sb-footer { padding: 12px; border-top: 1px solid var(--border); }

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
.main { margin-left: 230px; flex: 1; min-height: 100vh; }
.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar h3 { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.page { padding: 24px 28px; }

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.sgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.sc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 20px; transition: transform .15s;
}
.sc:hover { transform: translateY(-2px); }
.sc .sl { font-size: 11px; color: var(--text2); font-weight: 600; text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.sc .sv { font-family: 'Syne', sans-serif; font-size: 32px; font-weight: 800; line-height: 1; }
.sc .ss { font-size: 12px; color: var(--text2); margin-top: 6px; }
.sc.blue .sv   { color: var(--accent); }
.sc.green .sv  { color: var(--green); }
.sc.yellow .sv { color: var(--yellow); }
.sc.purple .sv { color: var(--accent2); }
.sc.red .sv    { color: var(--red); }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; overflow: hidden; margin-bottom: 20px;
}
.card-hdr {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-hdr h4 { font-size: 15px; font-weight: 700; }
.card-hdr .meta { font-size: 12px; color: var(--text2); }

/* ══════════════════════════════════════════
   TABLES
══════════════════════════════════════════ */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .7px;
  color: var(--text2); background: var(--surface2); white-space: nowrap;
}
td { padding: 11px 16px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.total-row td { background: var(--surface2); font-weight: 700; }
.empty { text-align: center; padding: 48px; color: var(--text2); }
.empty .ei { font-size: 40px; margin-bottom: 12px; }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 4px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.b-new   { background: rgba(79,142,247,.15);  color: var(--accent); }
.b-int   { background: rgba(34,201,129,.15);  color: var(--green); }
.b-demo  { background: rgba(124,90,245,.15);  color: var(--accent2); }
.b-conv  { background: rgba(245,200,66,.15);  color: var(--yellow); }
.b-noint { background: rgba(242,92,92,.15);   color: var(--red); }
.b-ring  { background: rgba(138,151,176,.15); color: var(--text2); }
.b-fu-g  { background: rgba(34,201,129,.15);  color: var(--green);  border: 1px solid rgba(34,201,129,.3); }
.b-fu-y  { background: rgba(245,200,66,.20);  color: var(--yellow); border: 1px solid rgba(245,200,66,.4); }
.b-fu-r  {
  background: rgba(242,92,92,.15); color: var(--red);
  border: 1px solid rgba(242,92,92,.4);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:.6; } }

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.mo {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.72);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: mIn .2s ease;
}
@keyframes mIn { from { opacity:0; transform:scale(.96) translateY(10px); } to { opacity:1; transform:none; } }
.m-hdr { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.m-hdr h3 { font-size: 16px; font-weight: 700; }
.m-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 22px; line-height: 1; padding: 2px 6px; }
.m-close:hover { color: var(--text); }
.m-body { padding: 24px; }
.m-foot { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ══════════════════════════════════════════
   MISC COMPONENTS
══════════════════════════════════════════ */
.isel {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 12px;
  padding: 5px 8px; cursor: pointer; max-width: 172px;
  font-family: 'DM Sans', sans-serif;
}
.isel:focus { outline: none; border-color: var(--accent); }

.sbar {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 9px; padding: 8px 14px;
}
.sbar input {
  background: none; border: none; color: var(--text);
  font-size: 13px; font-family: 'DM Sans', sans-serif;
  flex: 1; min-width: 120px;
}
.sbar input:focus { outline: none; }

.tabs {
  display: flex; gap: 4px; background: var(--surface2);
  padding: 4px; border-radius: 10px; margin-bottom: 20px; flex-wrap: wrap;
}
.tab { padding: 8px 16px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text2); transition: all .15s; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; margin-bottom: 16px; display: flex; align-items: flex-start; gap: 8px; }
.alert-info { background: rgba(79,142,247,.10); border: 1px solid rgba(79,142,247,.3); color: var(--accent); }
.alert-ok   { background: rgba(34,201,129,.10); border: 1px solid rgba(34,201,129,.3); color: var(--green); }
.alert-err  { background: rgba(242,92,92,.10);  border: 1px solid rgba(242,92,92,.3);  color: var(--red); }

.toggle { position: relative; display: inline-block; width: 40px; height: 22px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.tslider { position: absolute; cursor: pointer; inset: 0; background: var(--surface3); border-radius: 22px; transition: .3s; }
.tslider::before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: var(--text2); border-radius: 50%; transition: .3s; }
.toggle input:checked + .tslider { background: var(--accent); }
.toggle input:checked + .tslider::before { transform: translateX(18px); background: #fff; }

/* ── TOAST ── */
#toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--surface); border: 1px solid var(--border);
  padding: 14px 20px; border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.4);
  font-size: 13px; font-weight: 500;
  transform: translateY(80px); opacity: 0;
  transition: all .3s; display: flex; align-items: center; gap: 10px; max-width: 340px;
}
#toast.show  { transform: translateY(0); opacity: 1; }
#toast.ok    { border-color: rgba(34,201,129,.4); }
#toast.err   { border-color: rgba(242,92,92,.4); }

/* ── SPINNER ── */
.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DATE INPUT ── */
.date-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 10px 14px;
  width: 100%; font-family: 'DM Sans', sans-serif; font-size: 13px; cursor: pointer;
}
.date-input:focus { outline: none; border-color: var(--accent); }

/* ── INLINE NOTE INPUT ── */
.note-input {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text); padding: 5px 9px;
  font-size: 12px; width: 100%; font-family: 'DM Sans', sans-serif;
}
.note-input:focus { outline: none; border-color: var(--accent); }

/* ── HAMBURGER / OVERLAY ── */
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 22px; cursor: pointer; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; display: none; }
.overlay.show { display: block; }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .sgrid { grid-template-columns: repeat(2, 1fr); }
  .frow  { grid-template-columns: 1fr; }
  .page  { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .topbar-right { gap: 6px; }
  table { font-size: 12px; }
  th, td { padding: 9px 12px; }
}
@media (max-width: 480px) {
  .login-box { padding: 32px 24px; }
  .sgrid { grid-template-columns: 1fr 1fr; }
}
