/* =====================================================
   Parin CRM - Stylesheet
   ===================================================== */

:root{
  --bg:#0b1220; --card:#111b2e; --text:#e9efff; --muted:#8ea0c7;
  --accent:#6ea8fe; --ok:#4ade80; --warn:#fbbf24; --bad:#fb7185;
  --border:rgba(142,160,199,.18);
  --border2:rgba(34,50,82,.7);
  --radius:14px;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}
*{ box-sizing:border-box; }
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: hidden;
}
body{
  font-family:var(--sans);
  background: radial-gradient(1200px 700px at 20% 0%, #16254a 0%, var(--bg) 60%);
  color:var(--text);
}
header{
  position: sticky; top:0; z-index: 50;
  background: rgba(11,18,32,.85);
  backdrop-filter: blur(10px);
  border-bottom:1px solid rgba(34,50,82,.6);
}
.wrap{ margin:0 auto; padding: 14px 16px; }
.topbar{ display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; }
.brand h1{ margin:0; font-size:16px; }
.brand small{ display:block; color:var(--muted); font-size:12px; margin-top:2px; }
.actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
button, .btn{
  border:1px solid var(--border);
  background: linear-gradient(180deg, rgba(32,52,93,.95), rgba(27,42,73,.95));
  color:var(--text);
  padding: 9px 12px;
  border-radius:12px;
  cursor:pointer;
  font-weight:700;
  font-size:13px;
  box-shadow: 0 8px 18px rgba(0,0,0,.25);
}
button:hover{ border-color: rgba(110,168,254,.35); }
button.primary{
  background: linear-gradient(180deg, rgba(110,168,254,.95), rgba(110,168,254,.75));
  color:#041025;
  border-color: rgba(110,168,254,.75);
}
button.danger{
  background: transparent;
  border-color: rgba(251,113,133,.35);
  color:#ffb3ba;
  box-shadow:none;
}
button.ghost{ background:transparent; box-shadow:none; }
button.small{ padding: 7px 10px; font-size:12px; border-radius:10px; box-shadow:none; }

.tabs{ margin-top:12px; display:flex; gap:8px; flex-wrap:wrap; }
.tab{
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor:pointer;
  user-select:none;
  font-size:13px;
}
.tab.active{
  color: var(--text);
  border-color: rgba(110,168,254,.35);
  background: rgba(110,168,254,.12);
}

main .wrap{ padding: 18px 16px 40px; }
.grid{ display:grid; grid-template-columns: 1.2fr .8fr; gap:14px; align-items:start; }
@media (max-width: 980px){ .grid{ grid-template-columns: 1fr; } }

.card{
  background: linear-gradient(180deg, rgba(17,27,46,.92), rgba(17,27,46,.78));
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow:hidden;
}
.card .hd{
  padding: 14px 14px 10px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap:10px;
  border-bottom: 1px solid rgba(34,50,82,.55);
}
.card .hd h2{ margin:0; font-size:14px; }
.card .bd{ padding: 12px 14px 14px; }

.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; }
.row > *{ flex: 1; min-width: 160px; }
.row .tight{ flex: 0; min-width: 160px; }

label{ display:block; font-size:12px; color: var(--muted); margin: 2px 0 6px; }
input, select, textarea{
  width:100%;
  background: rgba(8,12,22,.45);
  border:1px solid var(--border);
  color: var(--text);
  padding: 10px 10px;
  border-radius:12px;
  outline:none;
  font-size:13px;
}
textarea{ min-height: 70px; resize: vertical; }
input::placeholder, textarea::placeholder{ color: rgba(142,160,199,.65); }

table{ width:100%; border-collapse: collapse; font-size:13px; }
thead th{
  text-align:left;
  font-size:12px;
  color:var(--muted);
  font-weight:800;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(34,50,82,.55);
}
tbody td{
  padding: 10px 8px;
  border-bottom: 1px solid rgba(34,50,82,.35);
  vertical-align: top;
}
tbody tr:hover{ background: rgba(110,168,254,.06); }

.pill{
  display:inline-flex; align-items:center; gap:6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size:12px;
  border: 1px solid rgba(142,160,199,.18);
  color: var(--muted);
  background: rgba(142,160,199,.08);
  white-space: nowrap;
}
.pill.ok{ border-color: rgba(74,222,128,.35); color:#d7ffe6; background: rgba(74,222,128,.08); }
.pill.warn{ border-color: rgba(251,191,36,.35); color:#ffe9b0; background: rgba(251,191,36,.08); }
.pill.bad{ border-color: rgba(251,113,133,.35); color:#ffc1c9; background: rgba(251,113,133,.08); }
.pill.accent{ border-color: rgba(110,168,254,.35); color:#cfe1ff; background: rgba(110,168,254,.10); }

.right{ text-align:right; }
.muted{ color: var(--muted); font-size:12px; }
.mono{ font-family: var(--mono); font-size: 12px; }
.small{ font-size:12px; }

.modalOverlay{
  position:fixed; inset:0;
  background: rgba(0,0,0,.55);
  display:none;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 120;
}
.modalOverlay.open{ display:flex; }
.modal{
  width: min(1100px, 100%);
  max-height: 92vh;
  overflow:auto;
  background: linear-gradient(180deg, rgba(17,27,46,.98), rgba(17,27,46,.92));
  border: 1px solid rgba(34,50,82,.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal .hd{
  padding: 14px 14px 10px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  border-bottom: 1px solid rgba(34,50,82,.55);
  gap:10px;
}
.modal .hd h3{ margin:0; font-size:14px; }
.modal .bd{ padding: 12px 14px 14px; }

.split{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px){ .split{ grid-template-columns: 1fr; } }

.subcard{
  border:1px solid rgba(34,50,82,.55);
  border-radius: 12px;
  padding: 10px;
  background: rgba(8,12,22,.25);
  margin-bottom: 10px;
}

.toast{
  position: fixed;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  background: rgba(17,27,46,.96);
  border: 1px solid rgba(34,50,82,.9);
  padding: 10px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  display:none;
  z-index: 200;
  font-size: 13px;
}
.toast.show{ display:block; }
.kbd{
  font-family: var(--mono);
  font-size: 12px;
  color: #dbe6ff;
  border: 1px solid rgba(142,160,199,.2);
  background: rgba(142,160,199,.06);
  padding: 2px 6px;
  border-radius: 8px;
}

#loginScreen{
  min-height: 100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 20px;
}
#loginCard{
  width: min(420px, 100%);
  background: linear-gradient(180deg, rgba(17,27,46,.95), rgba(17,27,46,.85));
  border: 1px solid rgba(34,50,82,.8);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
#appShell{ display:none; }

.notice{
  border:1px dashed rgba(110,168,254,.35);
  background: rgba(110,168,254,.08);
  padding: 10px;
  border-radius: 12px;
  color: #cfe1ff;
  font-size:12px;
}
.err{
  border:1px dashed rgba(251,113,133,.45);
  background: rgba(251,113,133,.08);
  padding: 10px;
  border-radius: 12px;
  color: #ffd1d7;
  font-size:12px;
}

.waIconBtn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  width:28px;
  height:28px;
  border-radius:10px;
  border:1px solid rgba(142,160,199,.18);
  background: rgba(142,160,199,.08);
  cursor:pointer;
  padding:0;
}
.waIconBtn:hover{ border-color: rgba(37, 211, 102, .55); }
.waCell{
  display:flex;
  align-items:center;
  gap:8px;
  flex-wrap:wrap;
}

.userCard{
  border:1px solid rgba(34,50,82,.55);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display:flex;
  justify-content: space-between;
  align-items:center;
  gap:10px;
  background: rgba(8,12,22,.15);
}
.userCard:hover{ background: rgba(110,168,254,.06); }


/* Your main container class/ID - adjust if needed */
.main, .container, .main-container, #app, body > main {
  width: 100vw !important;
  max-width: 100vw !important;
  margin: 0 !important;
  padding: 0 8px !important;
  box-sizing: border-box !important;
}

/* Tables fit screen */
table, #callsTable, #partiesTable {
  width: 100% !important;
  table-layout: fixed !important;
  border-collapse: collapse !important;
}

/* Tight column spacing */
table th, table td {
  padding: 6px 4px !important;  /* Half the usual padding */
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

/* Column widths - adjust nth-child numbers to match your tables */
th:nth-child(5), td:nth-child(5) { width: 50px !important; }  /* ID */
th:nth-child(1), td:nth-child(1) { width: 200px !important; } /* Main content */
th:nth-child(2), td:nth-child(2) { width: 120px !important; }
th:nth-child(3), td:nth-child(3) { width: 100px !important; }
th:nth-child(4), td:nth-child(4) { width: 80px !important; }
th:last-child, td:last-child { width: 70px !important; }     /* Edit button */



/* Mobile: allow horizontal scroll instead of truncation */
@media (max-width: 768px) {
  /* Let content decide width; scroll container will handle overflow */
  table {
    table-layout: auto !important;
  }

  /* Disable ellipsis/clipping that hides text + buttons */
  table th,
  table td {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important; /* enables horizontal scroll instead of wrapping */
  }

  /* Keep your Notes cells readable (you already render notes with pre-wrap inline style) */
  table td[style*="white-space:pre-wrap"] {
    white-space: pre-wrap !important;
  }

  /* Ensure action buttons (Edit/Close) are not cut off on mobile */
  #viewHome table th:last-child,
  #viewHome table td:last-child,
  #viewCalls table th:last-child,
  #viewCalls table td:last-child,
  #viewParties table th:last-child,
  #viewParties table td:last-child {
    min-width: 160px !important;
    width: auto !important;
  }

  /* Home tab: Due + Party need room */
  #viewHome table th:nth-child(5),
  #viewHome table td:nth-child(5) {
    min-width: 120px !important;
  }

  #viewHome table th:nth-child(1),
  #viewHome table td:nth-child(1) {
    min-width: 220px !important;
  }

  /* Calls tab: Due + Party + Outcome + Notes need room */
  #viewCalls table th:nth-child(5),
  #viewCalls table td:nth-child(5) {
    min-width: 120px !important;
  }
  #viewCalls table th:nth-child(1),
  #viewCalls table td:nth-child(1) {
    min-width: 240px !important;
  }
  #viewCalls table th:nth-child(3),
  #viewCalls table td:nth-child(3) {
    min-width: 180px !important;
  }
  #viewCalls table th:nth-child(4),
  #viewCalls table td:nth-child(4) {
    min-width: 260px !important;
  }

  /* Slightly improve button spacing in the Actions column */
  td.right button {
    margin-left: 6px;
  }
}
