/* ===== THEME TOKENS ===== */
:root {
  /* Dark (default) */
  --bg: #0f1115;
  --card: #151922;
  --settings-card: #000000;
  --kpi-card: #070e19;
  --text: #ffffff;
  --muted: #98a2b3;
  --hover: #1a2030;

  --nav: #000000;
  --border: #1e2430;
  --card-border: #000000;
  --card-kpi-border: #1b273e;
  --input: #0f1420;

  --accent: #4ade80;
  --accent-2: #60a5fa;
  --danger: #ef4444;

  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --shadow-soft: 0 6px 18px rgba(0,0,0,.22);
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 22px;
  --max: 1100px;

  /* New: consistent page padding + tap sizing */
  --page-pad: 16px;
  --tap: 44px;
}

/* Light overrides (tokens only) */
:root[data-theme="light"] {
  --bg: #ffffff;
  --card: #fdfdfd;
  --kpi-card: #dde8f4;
  --settings-card: #ffffff;
  --text: #000000;
  --muted: #111827;
  --hover: #f5f7fc;

  --nav: #ffffff;
  --border: #d9dfeb;
  --card-border: #e5e7eb;
  --card-kpi-border: #a7b3c1;
  --input: #f5f7fc;
}

/* ===== GLOBAL ===== */
* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, Arial, sans-serif;
  line-height: 1.45;
}

body {
  background:
    radial-gradient(1200px 500px at 5% -15%, rgba(96,165,250,.12), transparent 55%),
    radial-gradient(1000px 400px at 100% 0%, rgba(74,222,128,.08), transparent 60%),
    var(--bg);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }

/* Helpful utility class (your HTML uses .muted a lot) */
.muted { color: var(--muted); }

/* Better typography scaling for mobile */
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); line-height: 1.15; }
h2 { font-size: clamp(1.25rem, 3vw, 1.7rem); line-height: 1.2; }
h3 { font-size: 1.1rem; line-height: 1.25; }

/* Layout container */
.container {
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--page-pad);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 12px 18px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b0b0b;
  font-weight: 700;
  box-shadow: var(--shadow-soft);
  border: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .2s ease, opacity .15s ease;
}
.btn:hover {
  opacity: .96;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn.secondary {
  background: #000000;
  color: #ffffff;
  border: 1px solid #2f3645;
}

.btn.theme {
  background: #1b273e;
  color: var(--text);
  border: 1px solid #2f3645;
}

/* ===== NAVIGATION ===== */
nav {
  position: sticky;
  top: 0;
  background: var(--nav);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

/* Force one-line nav everywhere */
.nav-wrap {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-block: 10px;
  flex-wrap: nowrap; /* CHANGED: no multi-line nav */
}

/* Logo */
nav .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  justify-self: start;
}

nav .logo img {
  border-radius: 8px;
  object-fit: contain;
  max-height: 46px; /* CHANGED: smaller logo to preserve one-line nav */
  width: auto;
}

/* Company name */
.company-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

/* Main nav */
nav ul {
  list-style: none;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;

  /* CHANGED: never wrap; scroll horizontally if needed */
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  justify-content: center;
}

/* optional: hide scrollbar visually */
nav ul::-webkit-scrollbar { height: 0; }

/* Make nav links easier to tap */
nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 8px 12px;
  border-radius: 8px;
  white-space: nowrap;
}

nav a.active, nav a:hover { background: var(--hover); }
nav a.active { font-weight: 600; }

:root[data-theme="light"] nav a.active,
:root[data-theme="light"] nav a:hover { background: #e5ebf8; }

/* Hide company name sooner to keep nav single-line */
@media (max-width: 900px) {
  .company-name { display: none; }
}

/* ===== HERO / CARDS / GRIDS ===== */
.hero {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1.2fr .8fr;
  align-items: start;
  margin-top: 18px;
}


.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-soft);
  transition: transform .18s ease, box-shadow .2s ease, border-color .2s ease;
}
.card h3 { margin-top: 0; }
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: #2a3448;
}

/* Make the hero cards match existing look */
.hero .card {
  background: linear-gradient(180deg, var(--card), var(--card));
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.grid { display: grid; gap: var(--gap); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.kpi {
  background: var(--kpi-card);
  border: 1px solid var(--card-kpi-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  transition: transform .18s ease, border-color .2s ease;
}
.kpi:hover {
  transform: translateY(-2px);
  border-color: #36507f;
}
.kpi h3 { margin: 0; font-size: 28px; }
.kpi p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* ===== FORMS ===== */
form { display: grid; gap: 14px; }
.input { display: grid; gap: 8px; }

input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #2b3550;
  background: var(--input);
  color: var(--text);
}

textarea { min-height: 120px; }

input:focus, select:focus, textarea:focus {
  outline: 2px solid #3f98ff;
  border-color: #2d8cff;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
}

.error { color: var(--danger); font-size: 13px; }

/* Date/time inputs (theme-safe) */
input[type="date"],
input[type="time"] {
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  opacity: .9;
  cursor: pointer;
}

/* ===== FOOTER ===== */
footer { margin-top: 40px; border-top: 1px solid var(--border); }
footer .foot {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  flex-wrap: wrap;
  color: var(--muted);
  padding: 18px 0;
}

/* ===== DROPDOWN (Settings) ===== */
.dropdown { position: relative; display: inline-block; }

.dropbtn {
  background: var(--settings-card);
  color: var(--text);
  border: 1px solid var(--card-border);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 20px;
  min-height: var(--tap);
  min-width: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 110%;
  background: var(--card);
  min-width: 220px;
  box-shadow: var(--shadow-soft);
  z-index: 20;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
  padding: 10px;
}

.dropdown-content.show { display: block; }

.dropdown-item {
  width: 100%;
  padding: 10px 12px;
  text-decoration: none;
  display: block;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.dropdown-item:hover { background-color: var(--hover); }

.dropdown-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  padding: 0 2px 6px;
}

.dropdown-select {
  width: 100%;
  margin: 0 0 10px;
  min-height: 40px;
  padding: 8px 34px 8px 10px;
  border-radius: 8px;
  border: 1px solid #2b3550;
  background: var(--input);
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 3px), calc(100% - 11px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.dropdown-select:focus {
  outline: 2px solid #3f98ff;
  border-color: #2d8cff;
}

/* ===== ADMIN / TABLES ===== */
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  min-width: 720px; /* makes horizontal scroll predictable on phones */
}
.table th, .table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.table th {
  background: var(--card);
  font-weight: 600;
  color: var(--text);
}
.table tbody tr:hover { background: rgba(255,255,255,0.02); }
.table tbody tr:last-child td { border-bottom: none; }
.table th { position: sticky; top: 0; z-index: 1; }

.nowrap { white-space: nowrap; }

.message-preview {
  max-width: 320px;
  max-height: 3em;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  white-space: pre-wrap;
}

/* Notification */
.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  z-index: 1000;
  animation: slideIn 0.3s ease;
  max-width: min(360px, calc(100vw - 32px));
}
.notification-success { background-color: #28a745; }
.notification-error { background-color: #dc3545; }

@keyframes slideIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ================================
   MOBILE: make everything smaller
   (nav already handled above)
   ================================ */
@media (max-width: 640px) {
  html { font-size: 14px; }

  :root { --gap: 14px; }

  .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  .card { padding: 14px; }
  .hero .card { padding: 16px; }

  .hero { margin-top: 12px; gap: 12px; }

  h1 { font-size: 1.45rem; line-height: 1.2; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.02rem; }

  .kpi { padding: 12px; }
  .kpi h3 { font-size: 22px; }
  .kpi p { font-size: 12px; }

  input, select, textarea {
    padding: 10px 12px;
  }

  textarea { min-height: 96px; }

  .grid { gap: 14px; }

  .btn { width: 100%; }
}
