/* NTG Platform v4.1 – Polished Layout & Forms */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --text2: #374151;
  --muted: #6b7280;
  --primary: #0f172a;
  --accent: #2563eb;
  --accent-bg: #eff6ff;
  --success: #059669;
  --success-bg: #ecfdf5;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --info: #4f46e5;
  --info-bg: #eef2ff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06);
  --sidenav-w: 260px;
  --topbar-h: 56px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

.layout { display: flex; min-height: 100vh; }

/* SIDENAV */
.sidenav {
  width: var(--sidenav-w);
  background: var(--primary);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 400;
  transition: transform .28s ease;
  overflow: hidden;
}
.sidenav-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}
.sidenav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.sidenav-brand:hover { text-decoration: none; opacity: .95; }
.sidenav-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
}
.sidenav-title { font-weight: 700; font-size: 15px; }
.sidenav-close {
  display: none;
  background: rgba(255,255,255,.1);
  border: 0;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}
.sidenav-close:hover { background: rgba(255,255,255,.2); }

.sidenav-project { padding: 0 14px 14px; flex-shrink: 0; }
.sidenav-project label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: rgba(255,255,255,.4);
  margin-bottom: 6px;
}
.sidenav-project select {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
}
.sidenav-project select option { background: #1e293b; color: #fff; }

.sidenav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
  -webkit-overflow-scrolling: touch;
}
.sidenav-group { margin-bottom: 18px; }
.sidenav-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: rgba(255,255,255,.35);
  padding: 0 10px;
  margin-bottom: 4px;
}
.sidenav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.7);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidenav-link:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidenav-link.is-active {
  background: rgba(255,255,255,.14);
  color: #fff;
  font-weight: 600;
}
.sidenav-icon {
  width: 20px;
  text-align: center;
  font-size: 14px;
  opacity: .85;
  flex-shrink: 0;
}
.sidenav-bottom {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidenav-logout:hover {
  background: rgba(220,38,38,.25) !important;
  color: #fca5a5 !important;
}

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 350;
  backdrop-filter: blur(2px);
}

/* MAIN */
.main-col {
  flex: 1;
  margin-left: var(--sidenav-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}
.topbar-start { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-page {
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-end { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.topbar-project {
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.topbar-user { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.topbar-name { font-size: 13px; font-weight: 600; color: var(--text2); }

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px; height: 40px;
  padding: 8px;
  background: none;
  border: 0;
  cursor: pointer;
  border-radius: 8px;
}
.burger:hover { background: var(--bg); }
.burger span {
  display: block;
  height: 2px;
  width: 20px;
  background: var(--text);
  border-radius: 1px;
}

.page {
  flex: 1;
  padding: 24px 28px 48px;
  max-width: 1100px;
  width: 100%;
}

/* PAGE HEADER - support old class names too */
.page-header, .page-heading, .page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header h1, .page-heading h1, .page-head h1 {
  font-size: 22px;
  font-weight: 750;
  letter-spacing: -.3px;
  margin: 0;
}
.page-desc, .page-sub { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* STATS */
.stats-row, .stat-grid, .cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card, .card-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .label, .stat-label, .card-label {
  font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 4px;
}
.stat-card .value, .stat-value, .card-value {
  font-size: 26px; font-weight: 800; letter-spacing: -.5px;
}
.stat-card.warn { border-color: #fecaca; background: #fffaf8; }
.stat-card.warn .value { color: var(--warning); }

/* CARDS */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header, .panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card-header h2, .panel-header h2, .card h2, .panel h2 {
  font-size: 14px; font-weight: 650; margin: 0;
}
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* TABLES */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table, table.data-table, table.table {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
}
th, td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--muted);
  background: #f9fafb;
  white-space: nowrap;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #fafbfc; }
table a { font-weight: 600; color: var(--text); }
table a:hover { color: var(--accent); }
code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.empty, .empty-state { text-align: center; padding: 40px 16px; color: var(--muted); }

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-muted { background: #f3f4f6; color: var(--muted); }

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  transition: background .15s, opacity .15s;
}
.btn:hover { text-decoration: none; opacity: .92; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: #1e293b; }
.btn-secondary, .btn-outline {
  background: var(--surface);
  color: var(--text2);
  border-color: #d1d5db;
}
.btn-secondary:hover, .btn-outline:hover { background: #f9fafb; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-block, .btn-full { width: 100%; }

/* FORMS */
label, .form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="file"], input[type="search"],
select, textarea,
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}
select, .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
input:focus, select:focus, textarea:focus,
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
textarea, .form-textarea { resize: vertical; min-height: 90px; }
small, .form-hint { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-group { margin-bottom: 16px; }
.form-row, .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-group.full { grid-column: 1 / -1; }
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.form-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.form-section:last-of-type { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.form-section h3, .form-section-title {
  font-size: 13px; font-weight: 700; color: var(--text); margin: 0 0 14px;
}
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.check-group { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.check-group label, .form-check {
  display: flex; align-items: center; gap: 8px;
  font-weight: 500; font-size: 13.5px; cursor: pointer;
}
.check-group input, .form-check input {
  width: 16px; height: 16px; accent-color: var(--accent);
}
.gps-box, .gps-capture-box {
  background: linear-gradient(135deg, #eff6ff, #f0f9ff);
  border: 1px dashed #93c5fd;
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  margin: 10px 0;
}

.toolbar, .filter-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.toolbar input, .toolbar select,
.filter-form input, .filter-form select {
  width: auto; min-width: 150px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
}

.detail-row, .dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.detail-row:last-child, .dl > div:last-child { border-bottom: 0; }
.detail-row span:first-child, .dl dt { color: var(--muted); font-weight: 500; }
.detail-row strong, .dl dd { font-weight: 600; text-align: right; margin: 0; }

.alert, .toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13.5px;
  font-weight: 500;
}
.alert-success, .toast-success { background: var(--success-bg); color: var(--success); border: 1px solid #a7f3d0; }
.alert-error, .alert-danger, .toast-error { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #fde68a; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #c7d2fe; }
.alert-x, .toast-close {
  background: none; border: 0; font-size: 16px; cursor: pointer;
  opacity: .5; color: inherit; padding: 0 4px; line-height: 1;
}
.alert-x:hover, .toast-close:hover { opacity: 1; }

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.media-item, .media-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #f9fafb;
}
.media-item img, .media-card img { width: 100%; height: 110px; object-fit: cover; }
.media-meta { padding: 8px 10px; font-size: 12px; }

.auth-page, .login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(160deg, #0f172a 0%, #1e293b 100%);
}
.auth-card, .login-card {
  width: min(100%, 400px);
  background: #fff;
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.auth-brand, .brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.auth-brand h1, .brand h1 { font-size: 18px; font-weight: 700; margin: 0; }
.auth-brand p, .brand p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.auth-sub, .muted { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.login-footer, .auth-footer {
  display: flex; justify-content: space-between; margin-top: 24px;
  font-size: 12px; color: var(--muted);
}
.brand-mark, .brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 10px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 14px;
}
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-success { color: var(--success); font-weight: 700; }

/* RESPONSIVE */
@media (max-width: 1100px) {
  .stats-row, .stat-grid, .cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
  .sidenav { transform: translateX(-100%); }
  .layout.nav-open .sidenav { transform: translateX(0); }
  .layout.nav-open .nav-overlay { display: block; }
  .sidenav-close { display: grid; place-items: center; }
  .main-col { margin-left: 0; }
  .burger { display: flex; }
  .topbar-name { display: none; }
  .topbar-project { display: none; }
  .page { padding: 16px 16px 40px; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row, .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stats-row, .stat-grid, .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card .value, .stat-value, .card-value { font-size: 22px; }
  .page-header h1, .page-heading h1, .page-head h1 { font-size: 18px; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; justify-content: center; }
  .form-card { padding: 16px; }
  .media-grid { grid-template-columns: 1fr 1fr; }
  .auth-card, .login-card { padding: 24px 20px; }
}
@media (max-width: 400px) {
  .stats-row, .stat-grid, .cards { grid-template-columns: 1fr; }
}

/* ========== LANG + THEME CONTROLS ========== */
.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border-radius: 8px;
  padding: 2px;
  border: 1px solid var(--border);
}
.lang-btn {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-decoration: none;
  transition: background .2s, color .2s;
}
.lang-btn:hover { color: var(--text); text-decoration: none; }
.lang-btn.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: var(--shadow);
}
.theme-toggle {
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  font-size: 16px;
  color: var(--text2);
  display: grid;
  place-items: center;
  transition: background .2s, transform .2s;
}
.theme-toggle:hover { background: var(--bg); transform: rotate(30deg); }

/* ========== SMOOTH TRANSITIONS ========== */
.sidenav {
  transition: transform .32s cubic-bezier(.4,0,.2,1), box-shadow .32s ease;
}
.nav-overlay {
  transition: opacity .28s ease;
  opacity: 0;
  pointer-events: none;
}
.layout.nav-open .nav-overlay {
  display: block;
  opacity: 1;
  pointer-events: auto;
}
.sidenav-link {
  transition: background .18s ease, color .18s ease, transform .15s ease;
}
.sidenav-link:hover { transform: translateX(2px); }
.btn, .form-input, .form-select, .form-textarea, select, input, textarea {
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, opacity .15s ease, color .15s ease;
}
.card, .stat-card, .panel {
  transition: box-shadow .2s ease, border-color .2s ease;
}
.card:hover, .stat-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.07); }
table tr { transition: background .12s ease; }
.badge { transition: background .15s, color .15s; }

/* ========== DARK MODE ========== */
html.dark {
  --bg: #0b1220;
  --surface: #111827;
  --border: #1f2a3a;
  --text: #f1f5f9;
  --text2: #cbd5e1;
  --muted: #94a3b8;
  --primary: #0b1220;
  --accent: #60a5fa;
  --accent-bg: #1e3a5f;
  --success: #34d399;
  --success-bg: #064e3b;
  --warning: #fbbf24;
  --warning-bg: #78350f;
  --danger: #f87171;
  --danger-bg: #7f1d1d;
  --info: #a5b4fc;
  --info-bg: #312e81;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
}
html.dark body { background: var(--bg); color: var(--text); }
html.dark .sidenav {
  background: #020617;
  border-right: 1px solid #1e293b;
}
html.dark .topbar {
  background: var(--surface);
  border-bottom-color: var(--border);
}
html.dark .card,
html.dark .panel,
html.dark .stat-card,
html.dark .form-card {
  background: var(--surface);
  border-color: var(--border);
}
html.dark th { background: #0f172a; color: var(--muted); }
html.dark tr:hover td { background: #1e293b; }
html.dark input,
html.dark select,
html.dark textarea,
html.dark .form-input,
html.dark .form-select,
html.dark .form-textarea {
  background: #0f172a;
  border-color: #334155;
  color: var(--text);
}
html.dark code { background: #1e293b; color: #e2e8f0; }
html.dark .btn-secondary,
html.dark .btn-outline {
  background: #1e293b;
  border-color: #334155;
  color: var(--text2);
}
html.dark .lang-switch { background: #0f172a; border-color: #334155; }
html.dark .lang-btn.is-active { background: #1e293b; }
html.dark .theme-toggle { background: #1e293b; border-color: #334155; color: #e2e8f0; }
html.dark .gps-box {
  background: linear-gradient(135deg, #1e3a5f, #0f172a);
  border-color: #3b82f6;
}

/* Better mobile sidebar animation */
@media (max-width: 991px) {
  .sidenav {
    transform: translateX(-105%);
    box-shadow: none;
  }
  .layout.nav-open .sidenav {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.35);
  }
}
