@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ── FleetSpartan Admin — Platform Portal Layout ────────── */

:root {
  --sidebar-width: 248px;
  --sidebar-collapsed: 52px;
  --header-height: 52px;
  --sidebar-bg: #0a1f0e;
  --sidebar-text: #8fbf9a;
  --sidebar-hover: #132e18;
  --sidebar-active: #00c050;
  --sidebar-section-label: #4d7a56;
  --header-bg: #003008;
  --header-border: #004a10;
  --content-bg: #f5f8f6;
  --card-bg: #ffffff;
  --primary: #00a040;
  --primary-dark: #008030;
  --success: #1bc5bd;
  --warning: #ffa800;
  --danger: #f64e60;
  --info: #8950fc;
  --text-primary: #181c32;
  --text-muted: #a1a5b7;
  --border: #e4e6ef;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }

a, .btn-link { color: #0366d6; }
.btn-primary { color: #fff; background-color: #1b6ec2; border-color: #1861ac; }

/* ── Pin checkbox (hidden) ───────────────────────────────── */
.nav-pin-checkbox { display: none; }

/* ── Page shell ──────────────────────────────────────────── */
.platform-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  background: var(--content-bg);
}

/* ── Top Header Bar ──────────────────────────────────────── */
.platform-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-brand { display: flex; align-items: center; gap: 10px; user-select: none; }
.header-logo { height: 30px; width: auto; object-fit: contain; border-radius: 6px; }
.header-brand-text { font-size: 1.05rem; font-weight: 600; color: #a0e8b0; }
.header-right { display: flex; align-items: center; }

/* ── Sidebar ─────────────────────────────────────────────── */
.nav-sidebar {
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0;
  top: var(--header-height);
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  z-index: 100;
  transition: width 0.25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.nav-content {
  flex: 1;
  padding: 8px 6px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Slim scrollbar */
.nav-content::-webkit-scrollbar { width: 5px; }
.nav-content::-webkit-scrollbar-track { background: transparent; }
.nav-content::-webkit-scrollbar-thumb { background: #1a3d20; border-radius: 3px; }
.nav-content::-webkit-scrollbar-thumb:hover { background: #2a5d30; }

/* ── Nav sections ────────────────────────────────────────── */
.nav-section { margin: 4px 0; }
.nav-section-first { margin-top: 0; }

.nav-section-toggle {
  background: none; border: none;
  color: var(--sidebar-section-label);
  cursor: pointer;
  display: flex; align-items: center;
  font-size: 0.68rem; font-weight: 600;
  letter-spacing: 1.2px;
  padding: 8px 12px 4px;
  width: 100%; text-align: left;
  white-space: nowrap; font-family: inherit;
  text-transform: uppercase;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.nav-section-toggle:hover { color: #fff; background: var(--sidebar-hover); }

.section-chevron { font-size: 10px; margin-right: 6px; width: 12px; }

.section-collapsed { display: none; }
.section-expanded { display: block; }

/* Hover-expand collapsed sections */
.nav-section:hover .section-collapsed {
  display: block;
  animation: sectionFadeIn 0.2s ease;
}
@keyframes sectionFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.nav-section-items {
  margin-left: 4px;
  padding-left: 8px;
  border-left: 2px solid rgba(255,255,255,0.06);
}

/* ── Nav items ───────────────────────────────────────────── */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  border-radius: 6px;
  white-space: nowrap;
  transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { color: var(--sidebar-active); background: rgba(0,192,80,0.08); }
.nav-item i { font-size: 1.05rem; width: 20px; text-align: center; flex-shrink: 0; }

/* Label text + optional NEW badge (badge is not part of the label string) */
.nav-item-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.nav-badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 3px;
  background: rgba(0, 192, 80, 0.22);
  color: #5ee08a;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ── Nav footer ──────────────────────────────────────────── */
.nav-footer {
  padding: 8px 10px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.nav-footer-row { display: flex; align-items: center; }

.pin-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px; cursor: pointer;
  user-select: none; flex-shrink: 0;
  opacity: 0.4;
  transition: background 0.15s, opacity 0.15s;
}
.pin-toggle:hover { background: var(--sidebar-hover); opacity: 1; }
.pin-icon { font-size: 13px; color: var(--sidebar-text); }

.nav-version {
  flex: 1;
  font-size: 11px;
  color: #2a5d30;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}

/* ── Main content ────────────────────────────────────────── */
.platform-content {
  position: absolute;
  top: var(--header-height);
  left: var(--sidebar-width);
  right: 0; bottom: 0;
  overflow-y: auto;
  padding: 24px;
  background: var(--content-bg);
  transition: left 0.25s cubic-bezier(.4,0,.2,1);
}

/* Content scrollbar */
.platform-content::-webkit-scrollbar { width: 8px; }
.platform-content::-webkit-scrollbar-track { background: transparent; }
.platform-content::-webkit-scrollbar-thumb { background: #c0c5ce; border-radius: 4px; }
.platform-content::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ══════════════════════════════════════════════════════════
   Pin state — collapsed sidebar (CSS-only via checkbox)
   ══════════════════════════════════════════════════════════ */

/* Collapsed width */
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar { width: var(--sidebar-collapsed); }
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover { width: var(--sidebar-width); }
#nav-pin:not(:checked) ~ .platform-page .platform-content { left: var(--sidebar-collapsed); }

/* Hide text, section toggles, version when collapsed */
#nav-pin:not(:checked) ~ .platform-page .nav-item-text,
#nav-pin:not(:checked) ~ .platform-page .nav-version {
  opacity: 0; pointer-events: none; width: 0; overflow: hidden;
  transition: opacity 0.15s;
}
#nav-pin:not(:checked) ~ .platform-page .nav-section-toggle {
  display: none;
}

/* Force ALL section-items visible when collapsed */
#nav-pin:not(:checked) ~ .platform-page .nav-section-items {
  display: block !important;
  border-left: none; margin-left: 0; padding-left: 0;
}

/* Center icons when collapsed */
#nav-pin:not(:checked) ~ .platform-page .nav-item {
  justify-content: center; padding: 9px 0; gap: 0;
}
#nav-pin:not(:checked) ~ .platform-page .nav-item i {
  margin: 0; width: auto;
}

/* ── Hover-expand (with delay to prevent instant re-open) ── */
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar {
  transition: width 0.25s cubic-bezier(.4,0,.2,1) 0.3s;
}
/* Collapsing is instant when mouse leaves */
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:not(:hover) {
  transition: width 0.2s cubic-bezier(.4,0,.2,1) 0s;
}

/* Restore on hover */
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-item-text,
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-version {
  opacity: 1; pointer-events: auto; width: auto; overflow: visible;
}
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-section-toggle {
  display: flex;
}
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-section-items {
  border-left: 2px solid rgba(255,255,255,0.06); margin-left: 4px; padding-left: 8px;
}
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-item {
  justify-content: flex-start; padding: 9px 12px; gap: 10px;
}

/* Respect user's section collapse state when hovering */
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-section-items.section-collapsed {
  display: none !important;
}

/* Pin highlight when pinned */
#nav-pin:checked ~ .platform-page .pin-toggle { opacity: 1; background: rgba(0,192,80,0.15); }

/* Hide nav footer text when collapsed, show on hover */
#nav-pin:not(:checked) ~ .platform-page .nav-footer .nav-version { opacity: 0; }
#nav-pin:not(:checked) ~ .platform-page .nav-sidebar:hover .nav-footer .nav-version { opacity: 1; }

/* ══════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════ */

@media (max-width: 1024px) {
  .nav-sidebar { width: var(--sidebar-collapsed); }
  .nav-sidebar:hover { width: var(--sidebar-width); }
  .platform-content { left: var(--sidebar-collapsed); }
  .nav-item-text, .nav-version { opacity: 0; }
  .nav-section-toggle { display: none; }
  .nav-section-items { border-left: none; margin-left: 0; padding-left: 0; }
  .nav-sidebar:hover .nav-item-text, .nav-sidebar:hover .nav-version { opacity: 1; }
  .nav-sidebar:hover .nav-section-toggle { display: flex; }
  .nav-sidebar:hover .nav-section-items { border-left: 2px solid rgba(255,255,255,0.06); margin-left: 4px; padding-left: 8px; }
  .nav-item { justify-content: center; padding: 9px 0; gap: 0; }
  .nav-sidebar:hover .nav-item { justify-content: flex-start; padding: 9px 12px; gap: 10px; }
}

@media (max-width: 768px) {
  .platform-content { left: 0 !important; }
  .nav-sidebar { transform: translateX(-100%); }
  .nav-footer { display: none; }
  .header-brand-text { display: none; }
}

/* ── Cards & Panels ──────────────────────────────────────── */
.card { border: 1px solid var(--border); border-radius: 8px; background: var(--card-bg); box-shadow: 0 0 20px rgba(0,0,0,0.04); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; }

.stat-card {
  display: flex; align-items: center; gap: 16px; padding: 20px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 0 20px rgba(0,0,0,0.04);
}
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: #fff;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-muted); }

/* ── Page Header ─────────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.page-header .page-subtitle { color: var(--text-muted); font-size: 0.875rem; margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-platform { font-size: 0.875rem; }
.table-platform th { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; border-bottom-width: 2px; }
.table-platform td { vertical-align: middle; padding: 12px 8px; }

/* ── Badges ───────────────────────────────────────────────── */
.badge-active { background: rgba(27,197,189,0.12); color: #1bc5bd; }
.badge-inactive { background: rgba(246,78,96,0.12); color: #f64e60; }
.badge-system { background: rgba(137,80,252,0.12); color: #8950fc; }

/* ── Utility ──────────────────────────────────────────────── */
.bg-primary-soft { background: rgba(0,160,64,0.1); }
.bg-success-soft { background: rgba(27,197,189,0.1); }
.bg-warning-soft { background: rgba(255,168,0,0.1); }
.bg-danger-soft { background: rgba(246,78,96,0.1); }
.bg-info-soft { background: rgba(137,80,252,0.1); }

/* ── Validation ───────────────────────────────────────────── */
.content { padding-top: 1.1rem; }
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid red; }
.validation-message { color: red; }

#blazor-error-ui {
  background: lightyellow; bottom: 0;
  box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
  display: none; left: 0;
  padding: 0.6rem 1.25rem 0.7rem 1.25rem;
  position: fixed; width: 100%; z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

/* =============================================
   Two-Factor Authentication Shared Styles
   ============================================= */

.LoginCard {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  box-shadow: 0 20px 60px rgba(0, 96, 32, 0.15), 0 8px 16px rgba(0, 96, 32, 0.1);
  width: 480px; max-width: 90vw; overflow: hidden;
}

.LoginHeader {
  padding: 48px 48px 32px; text-align: center;
  background: linear-gradient(135deg, #006020 0%, #00a040 50%, #00c050 100%);
  position: relative; overflow: hidden;
}

.LoginLogo {
  width: 80px; height: 80px; margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
  position: relative; z-index: 1; border-radius: 16px;
  background: rgba(255, 255, 255, 0.9); padding: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.LoginTitle {
  font-size: 32px; font-weight: 700; color: white; margin: 0;
  letter-spacing: -0.5px; text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  position: relative; z-index: 1;
}

.LoginSubtitle {
  font-size: 16px; color: rgba(255, 255, 255, 0.9);
  margin-top: 8px; font-weight: 400; letter-spacing: 0.5px;
  position: relative; z-index: 1;
}

.LoginForm { padding: 40px 48px; }
.InputGroup { margin-bottom: 24px; }
.InputLabel { display: block; font-size: 14px; font-weight: 600; color: #2d3748; margin-bottom: 8px; letter-spacing: 0.3px; }

.InputField {
  width: 100%; padding: 14px 16px; font-size: 16px;
  border: 2px solid #e2e8f0; border-radius: 12px;
  background: white; color: #2d3748; transition: all 0.3s ease;
  box-sizing: border-box; font-family: inherit;
}
.InputField:focus { outline: none; border-color: #00a040; box-shadow: 0 0 0 4px rgba(0, 160, 64, 0.1); }
.InputField::placeholder { color: #a0aec0; }

.LoginActions { margin-top: 32px; }

.LoginButton {
  width: 100%; padding: 16px; font-size: 18px; font-weight: 600;
  color: white; background: linear-gradient(135deg, #00a040 0%, #00c050 100%);
  border: none; border-radius: 12px; cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 160, 64, 0.3);
  display: flex; align-items: center; justify-content: center;
  min-height: 56px; letter-spacing: 0.5px;
  text-transform: uppercase; font-family: inherit;
}
.LoginButton:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 160, 64, 0.4); background: linear-gradient(135deg, #00b848 0%, #00d458 100%); }
.LoginButton:disabled { opacity: 0.6; cursor: not-allowed; }

.ButtonSpinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white; border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ErrorMessage {
  margin-top: 20px; padding: 14px 16px;
  background: #fff5f5; border: 1px solid #fc8181;
  border-radius: 10px; color: #c53030; font-size: 14px;
  display: flex; align-items: center; gap: 10px;
}
.ErrorIcon { width: 20px; height: 20px; flex-shrink: 0; }

/* 2FA specific overrides */
.TwoFactorCard { width: 480px; max-width: 90vw; }
.EnrollmentCard { width: 560px; }

.EnrollmentInstructions { margin-bottom: 24px; text-align: center; }
.StepNumber { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #00a040; margin-bottom: 12px; }
.EnrollmentInstructions p { color: #4a5568; font-size: 14px; line-height: 1.6; margin: 0; }

.QRCodeContainer { display: flex; justify-content: center; margin: 24px 0; }
.QRCode { width: 200px; height: 200px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); }

.ManualEntrySection { text-align: center; margin-bottom: 24px; }
.ManualKey { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; padding: 12px 16px; background: #f7fafc; border-radius: 8px; }
.ManualKey code { font-family: 'Courier New', monospace; font-size: 14px; letter-spacing: 2px; color: #2d3748; }

.CopyButton { background: none; border: none; cursor: pointer; padding: 4px; color: #718096; transition: color 0.2s; }
.CopyButton:hover { color: #00a040; }
.CopyIcon { width: 18px; height: 18px; }

.LoadingContainer { text-align: center; padding: 40px; }
.LoadingContainer p { color: #718096; margin-top: 16px; }

.InputHint { font-size: 12px; color: #718096; margin-top: 6px; }
.CodeInput { font-family: 'Courier New', monospace; font-size: 24px; letter-spacing: 8px; text-align: center; padding: 16px; }

.TrustDeviceOption { margin-top: 20px; }
.CheckboxLabel { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: #4a5568; }
.CheckboxLabel input[type="checkbox"] { width: 18px; height: 18px; accent-color: #00a040; cursor: pointer; }

.TwoFactorOptions { margin-top: 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.LinkButton { background: none; border: none; color: #00a040; font-size: 14px; cursor: pointer; padding: 8px 12px; text-decoration: underline; font-family: inherit; }
.LinkButton:hover { color: #008030; }
.CancelLink { color: #718096; text-decoration: none; }
.CancelLink:hover { color: #4a5568; text-decoration: underline; }

/* Backup codes */
.ImportantNote { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; padding: 12px 16px; color: #92400e; }

.BackupCodesContainer {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin: 24px 0; padding: 16px;
  background: #f7fafc; border-radius: 8px;
}
.BackupCode { font-family: 'Courier New', monospace; font-size: 14px; padding: 8px 12px; background: white; border-radius: 4px; text-align: center; color: #2d3748; }

.BackupCodeActions { display: flex; justify-content: center; gap: 12px; margin-bottom: 20px; }

.SecondaryButton {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  color: #4a5568; background: white; border: 1px solid #e2e8f0;
  border-radius: 8px; cursor: pointer; transition: all 0.2s; font-family: inherit;
}
.SecondaryButton:hover { background: #f7fafc; border-color: #cbd5e0; }

.ButtonIcon { width: 16px; height: 16px; }
.ConfirmSaved { margin-bottom: 20px; display: flex; justify-content: center; }

/* Modal close button */
.modal-header .btn-close {
  background: transparent; border: none; font-size: 1.5rem; line-height: 1;
  color: #000; opacity: 0.5; cursor: pointer; padding: 0; width: 1.5rem; height: 1.5rem;
}
.modal-header .btn-close:hover { opacity: 1; }
.modal-header .btn-close::before { content: "\00d7"; }
