/* =========================================================
   TechOwl CRM – UI (v3)
   Works with main.js IDs/classes
========================================================= */

:root{
  --bg:#050816;
  --card:#0d1326;
  --text:#f5f6ff;
  --muted:#9aa3c7;
  --border:rgba(255,255,255,0.08);
  --accent:#4a90e2;
  --accent2:#61b0ff;
  --accentSoft:rgba(74,144,226,0.14);
  --danger:#ff4d4f;
  --shadow:0 18px 45px rgba(0,0,0,0.55);
}

*{box-sizing:border-box;}
html,body{height:100%;}
body{
  margin:0;
  font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  color:var(--text);
  background: var(--bg);
}

/* unified background everywhere */
#crm-view{
  min-height:100vh;
  background:
    radial-gradient(circle at top left, rgba(97,176,255,0.22) 0, transparent 55%),
    radial-gradient(circle at bottom right, rgba(116,83,186,0.22) 0, transparent 55%),
    var(--bg);
}

/* =========================================================
   Login
========================================================= */
#login-view{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
  background:
    radial-gradient(circle at top left, rgba(97,176,255,0.25) 0, transparent 55%),
    radial-gradient(circle at bottom right, rgba(116,83,186,0.25) 0, transparent 55%),
    var(--bg);
}
.login-card{
  width:min(520px, 100%);
  background:linear-gradient(145deg, rgba(18,26,52,0.95), rgba(8,10,22,0.95));
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:22px 20px;
  text-align:center;
}
.login-logo{
  height:56px;
  width:auto;
  display:block;
  margin:4px auto 8px;
}
.login-title{margin:0 0 6px; letter-spacing:0.02em;}
.login-subtitle{margin:0 0 14px; color:var(--muted); font-size:13px;}
.login-form{margin-top:8px;}
.field{display:block;text-align:left;margin-bottom:6px;}
.field-label{display:block;font-size:12px;color:var(--muted);margin:6px 0 4px;}
.error{color:var(--danger); font-size:13px; margin:10px 0 0;}

/* inputs/buttons */
input, select, textarea{
  width:100%;
  padding:10px 11px;
  border-radius:12px;
  border:1px solid var(--border);
  background:#060a18;
  color:var(--text);
  outline:none;
}
input:focus, select:focus, textarea:focus{
  border-color:rgba(97,176,255,0.8);
  box-shadow:0 0 0 2px rgba(74,144,226,0.20);
}

.btn{
  border:none;
  border-radius:999px;
  padding:10px 14px;
  font-weight:600;
  cursor:pointer;
  transition:transform .12s ease, filter .12s ease, box-shadow .12s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  white-space:nowrap;
}
.btn:hover{filter:brightness(1.06); transform:translateY(-1px);}
.btn:active{transform:translateY(0);}
.btn-primary{
  background:linear-gradient(135deg,var(--accent),var(--accent2));
  color:#fff;
  box-shadow:0 12px 25px rgba(0,0,0,0.35);
}
.btn-secondary{
  background:rgba(255,255,255,0.06);
  color:var(--text);
  border:1px solid var(--border);
}
.btn-ghost{
  background:transparent;
  border:1px solid var(--border);
  color:var(--text);
}
.btn-small{padding:8px 12px; font-size:12px;}

/* =========================================================
   Shell / Layout
========================================================= */
.container{
  width:min(1120px, calc(100% - 20px));
  margin:14px auto 70px; /* room for footer */
}
.topbar{
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(5,8,22,0.65);
  backdrop-filter:blur(10px);
  border-bottom:1px solid rgba(255,255,255,0.06);
}
.topbar-inner{
  width:min(1120px, calc(100% - 20px));
  margin:0 auto;
  padding:10px 0;
  display:grid;
  grid-template-columns: 1fr auto 1fr;
  align-items:center;
  gap:10px;
}

/* Center logo + nav */
.brand{display:flex;align-items:center;justify-content:center;}
.brand-logo{
  height:34px;
  width:auto;
  display:block;
  filter: drop-shadow(0 0 10px rgba(0,0,0,0.35));
}

/* NAV oval keep pills inside */
.nav-wrap{display:flex;justify-content:center;}
.nav-pills{
  display:flex;
  gap:6px;
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(6,10,24,0.70);
  overflow:hidden; /* keeps pills inside oval */
  max-width:100%;
}
.nav-btn{
  background:transparent;
  color:var(--muted);
  border:none;
  padding:7px 12px;
  border-radius:999px;
  font-size:13px;
  cursor:pointer;
  transition:background .15s ease, color .15s ease;
}
.nav-btn:hover{color:var(--text);}
.nav-active{
  background:var(--accentSoft);
  color:var(--accent2);
  box-shadow:inset 0 0 0 1px rgba(97,176,255,0.5);
}
.topbar-actions{display:flex;justify-content:center;}

/* =========================================================
   Cards, titles, tables
========================================================= */
.card{
  background:linear-gradient(145deg, rgba(18,26,52,0.92), rgba(8,10,22,0.92));
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:18px 16px;
  margin:14px 0;
}
.card.subtle{background:rgba(18,26,52,0.35); box-shadow:none;}
.section-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:12px;
}
.section-title{margin:0; letter-spacing:0.02em;}
.section-actions{display:flex; gap:8px; flex-wrap:wrap;}

.table-wrap{overflow:auto; border-radius:14px;}
.table{
  width:100%;
  border-collapse:collapse;
  min-width:720px;
}
.table th, .table td{
  padding:10px 10px;
  border-bottom:1px dashed rgba(255,255,255,0.08);
  text-align:left;
  font-size:13px;
}
.table th{
  color:var(--muted);
  font-weight:600;
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:0.06em;
}
.table tr:hover td{background:rgba(255,255,255,0.03);}

.hint{margin:12px 0 0; color:var(--muted); font-size:13px;}

/* KPIs */
.kpis-grid{
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:12px;
}
.kpi{
  padding:14px 12px;
  border-radius:16px;
  background:
    radial-gradient(circle at top left, rgba(97,176,255,0.25) 0, transparent 55%),
    rgba(6,10,24,0.6);
  border:1px solid rgba(255,255,255,0.07);
}
.kpi-label{
  font-size:11px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.kpi-value{font-size:22px; font-weight:700; margin-top:8px;}

/* Quick buttons */
.quick-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(150px, 1fr));
  gap:10px;
}

/* Settings preview pills */
.settings-preview{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px;}
.pill{
  padding:6px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(255,255,255,0.05);
  color:var(--muted);
  font-size:12px;
}

/* =========================================================
   Modal
========================================================= */
.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(2,4,12,0.78);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:1000;
  backdrop-filter:blur(10px);
}
.modal-window{
  width:min(820px, calc(100% - 20px));
  max-height:92vh;
  overflow:auto;
  background:linear-gradient(150deg, rgba(18,26,52,0.98), rgba(7,9,20,0.98));
  border:1px solid rgba(255,255,255,0.10);
  border-radius:18px;
  box-shadow:var(--shadow);
  padding:20px 18px 16px;
  position:relative;
}
.modal-close{
  position:absolute;
  top:12px;
  right:12px;
  width:38px;
  height:38px;
  border-radius:999px;
  border:none;
  background:var(--danger);
  color:#fff;
  font-size:18px;
  font-weight:900;
  cursor:pointer;
  box-shadow:0 0 0 3px rgba(255,77,79,0.35);
}
.modal-open .nav-btn,
.modal-open #btn-logout{
  pointer-events:none;
  opacity:0.55;
}

/* Settings tabs inside modal (used by main.js) */
.settings-tabs{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0 14px;}
.settings-tab-btn{
  width:auto;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:var(--muted);
  cursor:pointer;
  font-weight:600;
  font-size:12px;
}
.settings-tab-active{
  background:var(--accentSoft);
  color:var(--accent2);
  box-shadow:inset 0 0 0 1px rgba(97,176,255,0.5);
}
.settings-section-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin:8px 0 10px;
}
.settings-section-header h3{margin:0;}

/* =========================================================
   Footer fixed at bottom
========================================================= */
.footer{
  position:fixed;
  left:0; right:0; bottom:0;
  border-top:1px solid rgba(255,255,255,0.06);
  background:rgba(5,8,22,0.75);
  backdrop-filter:blur(10px);
  z-index:15;
}
.footer-inner{
  width:min(1120px, calc(100% - 20px));
  margin:0 auto;
  padding:10px 0;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  font-size:12px;
  color:var(--muted);
}
.footer-sep{opacity:.6;}
.muted{color:var(--muted);}

/* =========================================================
   Responsive
========================================================= */
@media (max-width: 980px){
  .kpis-grid{grid-template-columns:repeat(2, minmax(0, 1fr));}
  .table{min-width:640px;}
}
@media (max-width: 640px){
  .topbar-inner{grid-template-columns: 1fr; justify-items:center;}
  .container{margin-bottom:84px;}
  .kpis-grid{grid-template-columns:1fr;}
  .nav-pills{width:100%; justify-content:flex-start; overflow:auto;}
}


/* ================= Customer Card (modal) ================= */
.cc-tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:14px 0 10px;
}
.cc-tab{
  width:auto;
  padding:8px 12px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.10);
  background:rgba(255,255,255,0.04);
  color:var(--muted, #9aa3c7);
  cursor:pointer;
  font-weight:700;
  font-size:12px;
}
.cc-tab-active{
  background:rgba(74,144,226,0.14);
  color:rgba(97,176,255,1);
  box-shadow:inset 0 0 0 1px rgba(97,176,255,0.5);
}
.cc-grid{
  display:grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap:12px;
}
.cc-card{
  background:rgba(255,255,255,0.03);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  padding:14px 12px;
}
.cc-stats{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:10px;
}
.cc-stat{
  padding:10px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(6,10,24,0.55);
}
.cc-stat-label{
  font-size:11px;
  color:var(--muted, #9aa3c7);
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.cc-stat-val{
  font-size:18px;
  font-weight:800;
  margin-top:6px;
}
.cc-tx-summary{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr)) auto;
  gap:10px;
  align-items:end;
}
.cc-sum{
  padding:10px 10px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,0.08);
  background:rgba(6,10,24,0.55);
}
.cc-sum-label{
  font-size:11px;
  color:var(--muted, #9aa3c7);
  text-transform:uppercase;
  letter-spacing:0.08em;
}
.cc-sum-val{
  font-size:16px;
  font-weight:800;
  margin-top:6px;
}
.badge{display:inline-flex;align-items:center;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;}
.badge-sr{background:rgba(255,214,102,0.12);color:#ffd666;}
.badge-sub{background:rgba(97,176,255,0.12);color:#61b0ff;}
.badge-manual{background:rgba(180,180,180,0.14);color:#e0e0e0;}
.row-actions{white-space:nowrap;}

@media (max-width: 820px){
  .cc-grid{grid-template-columns:1fr;}
  .cc-tx-summary{grid-template-columns:1fr 1fr; }
}

/* Flatpickr (calendar popup) dark tweaks */
.flatpickr-calendar {
  background: rgba(10, 18, 40, 0.98);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 40px rgba(0,0,0,0.55);
}
.flatpickr-day, .flatpickr-weekday, .flatpickr-months .flatpickr-month {
  color: #eaf0ff;
}
.flatpickr-day:hover {
  background: rgba(97, 168, 255, 0.22);
}
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange {
  background: rgba(97, 168, 255, 0.65);
  border-color: rgba(97, 168, 255, 0.65);
}
.flatpickr-current-month .flatpickr-monthDropdown-months, .flatpickr-current-month input.cur-year {
  color: #eaf0ff;
}
