/* Base Styles & Responsive Viewport Rules — Workshop Fuel Tracker */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--mesh-base);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  min-height: 100dvh;
}

/* The mesh gradient on its own fixed layer: unlike background-attachment: fixed, scrolling does
   not repaint the viewport. html has no background, so body's colour stays beneath this layer. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: var(--mesh-bg);
}

@media print {
  body::before {
    display: none;
  }
}

h1, h2, h3, h4, h5, p {
  margin: 0;
}

/* The hidden attribute always wins over component display rules (e.g. .btn's inline-flex). */
[hidden] {
  display: none !important;
}

h1, h2, h3, h4 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

p {
  color: var(--muted);
}

a {
  color: var(--brand);
  text-decoration: none;
  transition: color 0.15s ease;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}

::selection {
  background: var(--fill-brand);
  color: #ffffff;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background: var(--line-3);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-2);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* -------------------------------------------------------------------------- */
/* App Layout Container Structure                                             */
/* -------------------------------------------------------------------------- */

#app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

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

/* ========================================================================== */
/* Executive Sidebar Navigation                                               */
/* ========================================================================== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-glass-bg);
  color: var(--text-2);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 70;
  display: flex;
  flex-direction: column;
  /* Only the phone/tablet drawer slides; collapsing on desktop changes the width at once. */
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 1px solid var(--sidebar-glass-border);
  box-shadow: 4px 0 24px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .sidebar {
  box-shadow: 4px 0 32px rgba(0, 0, 0, 0.45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--sidebar-glass-border);
  flex-shrink: 0;
  position: relative;
}

.sidebar-collapse-btn {
  margin-left: auto;
  background: var(--bg-hover);
  border: 1px solid var(--line);
  color: var(--text-2);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex-shrink: 0;
}

.sidebar-collapse-btn:hover {
  background: var(--fill-brand);
  color: #fff;
  border-color: var(--fill-brand);
}

@media (max-width: 1024px) {
  .sidebar-collapse-btn {
    display: none !important;
  }
}

/* Collapsed Sidebar State (Desktop) */
@media (min-width: 1025px) {
  .app.sidebar-collapsed {
    --sidebar-w: 68px;
  }

  .app.sidebar-collapsed .sidebar {
    width: 68px !important;
  }

  .app.sidebar-collapsed .main {
    margin-left: 68px !important;
  }

  .app.sidebar-collapsed .brand {
    padding: 14px 8px;
    justify-content: center;
  }

  .app.sidebar-collapsed .brand-mark {
    width: 38px;
    height: 38px;
  }

  .app.sidebar-collapsed .brand-text {
    display: none !important;
  }

  .app.sidebar-collapsed .sidebar-collapse-btn {
    position: absolute;
    top: 66px;
    right: -12px;
    background: var(--fill-brand);
    border: 1px solid var(--fill-brand-hover);
    color: #fff;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    z-index: 80;
    display: grid;
    place-items: center;
    transition: transform 0.15s ease, background 0.15s ease;
  }

  .app.sidebar-collapsed .sidebar-collapse-btn:hover {
    transform: scale(1.15);
    background: var(--brand-700);
  }

  .app.sidebar-collapsed .nav {
    padding: 8px 6px;
  }

  .app.sidebar-collapsed .nav-label {
    font-size: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 4px;
    padding: 0;
  }

  .app.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 11px 0;
    margin: 3px 0;
    border-radius: 8px;
  }

  .app.sidebar-collapsed .nav-item span {
    display: none !important;
  }

  .app.sidebar-collapsed .nav-badge {
    display: none !important;
  }

  .app.sidebar-collapsed .sidebar-user {
    padding: 12px 6px;
  }

  .app.sidebar-collapsed .su-row {
    justify-content: center;
  }

  .app.sidebar-collapsed .su-info {
    display: none !important;
  }

  .app.sidebar-collapsed .su-logout span {
    display: none !important;
  }

  .app.sidebar-collapsed .su-logout {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 4px auto 0 auto;
  }
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  color: var(--brand);
  font-weight: 800;
  font-size: 12px;
  display: grid;
  place-items: center;
}

.brand-title {
  color: var(--text);
  font-weight: 800;
  font-size: 14.5px;
  line-height: 1.25;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 2px;
}

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 14px 11px 6px;
  font-weight: 700;
}

.nav-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  background: transparent;
  border: 0;
  color: var(--text-2);
  padding: 10px 12px;
  border-radius: 10px;
  text-align: left;
  font-size: 13.5px;
  font-weight: 600;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
  position: relative;
  text-decoration: none;
  cursor: pointer;
}

.nav-item i,
.nav-item svg {
  width: 18px;
  height: 18px;
  flex: none;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--brand-50);
  color: var(--brand);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--fill-brand), var(--brand-700));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(26, 111, 196, 0.35);
}

.nav-item.active i,
.nav-item.active svg {
  opacity: 1;
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  background: var(--brand-50);
  color: var(--brand);
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 20px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

.nav-badge.warn {
  background: #fbbf24;
  color: #0b2545;
  font-weight: 800;
}

.sidebar-user {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-glass-border);
  flex-shrink: 0;
}

.su-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: inherit;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.su-av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(140deg, #1a6fc4, #0f4c81);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.su-info {
  flex: 1;
  min-width: 0;
}

.su-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.su-role {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-top: 1px;
}

.su-logout {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger);
  width: 100%;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.su-logout:hover {
  background: var(--fill-danger);
  color: #ffffff;
  border-color: var(--fill-danger);
}

.su-logout i,
.su-logout svg {
  font-size: 13px;
}

/* Mobile Bottom Navigation (Hidden on Desktop) */
.bottom-nav,
.mobile-nav-bottom {
  display: none !important;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
  padding: 4px 0;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item .bn-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  font-size: 17px;
  line-height: 1;
}

.bottom-nav-item i,
.bottom-nav-item svg {
  font-size: 17px;
}

.bottom-nav-item:hover {
  color: var(--brand);
}

.bottom-nav-item.active {
  color: var(--brand);
  font-weight: 700;
}

.bottom-nav-item.active .bn-icon-wrap i {
  transform: scale(1.15);
  color: var(--brand);
}

/* Elevated New Action Button in Center */
.bottom-nav-item.bn-new {
  position: relative;
}

.bottom-nav-item.bn-new .bn-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fill-brand), var(--brand-700));
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(26, 111, 196, 0.45);
  margin-top: -14px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 2px solid var(--card);
}

.bottom-nav-item.bn-new:hover .bn-icon-wrap,
.bottom-nav-item.bn-new.active .bn-icon-wrap {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 18px rgba(26, 111, 196, 0.6);
  background: linear-gradient(135deg, var(--fill-brand-hover), var(--brand-700));
}

.bottom-nav-item.bn-new span:last-child {
  font-weight: 700;
  font-size: 10.5px;
  margin-top: 2px;
}



/* Main Content Area beside Sidebar */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}

.content {
  padding: 22px 28px;
  flex: 1;
  max-width: 100%;
  width: 100%;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes popIn {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* Topbar Sticky Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 1px solid var(--glass-border-subtle);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-h);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.03);
}

[data-theme="dark"] .topbar {
  background: var(--glass-bg);
  border-bottom-color: var(--glass-border-subtle);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.hamburger {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--navy);
  flex-shrink: 0;
}

[data-theme="dark"] .hamburger {
  color: var(--text);
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.25px;
  line-height: 1.2;
}

.page-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-btn {
  text-decoration: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--text-2);
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.tb-btn:hover {
  background: var(--brand-50);
  color: var(--brand);
  border-color: var(--brand);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 69, 0.45);
  z-index: 65;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Tablet & Mobile Breakpoints */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    /* The drawer covers the page here, so it frosts what is under it. */
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
  }

  .hamburger {
    display: grid;
  }

  .content {
    padding: 16px 16px calc(76px + env(safe-area-inset-bottom, 0px)) 16px !important;
  }

  .topbar {
    padding: 10px 16px;
  }

  /* Docked Mobile Bottom Navigation Bar */
  .bottom-nav,
  .mobile-nav-bottom {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 60px !important;
    z-index: 60 !important;
    overflow: visible !important;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding: 0 8px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.08);
  }

  [data-theme="dark"] .bottom-nav,
  [data-theme="dark"] .mobile-nav-bottom {
    background: rgba(11, 25, 44, 0.95);
    border-top-color: var(--line);
    box-shadow: 0 -4px 22px rgba(0, 0, 0, 0.45);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 8px 12px;
    gap: 8px;
    min-height: 52px;
  }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
  }

  .page-title {
    font-size: 15px;
    font-weight: 700;
  }

  .page-sub {
    display: none;
  }

  /* Quick action in topbar: icon-only on mobile matching tb-btn & hamburger */
  #btn-quick-new span {
    display: none;
  }

  #btn-quick-new {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .hamburger,
  .tb-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    min-height: 38px;
    border-radius: 9px;
  }

  .content {
    padding: 12px 12px calc(76px + env(safe-area-inset-bottom, 0px)) 12px !important;
  }
}

/* Keyboard focus is always visible; mouse clicks do not draw the ring. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: none;
}

/* Offline queue indicator in the topbar */
.tb-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: var(--radius-full);
  border: 1px solid var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tb-chip.has-failed { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
@media (max-width: 520px) { #queue-chip-text { display: none; } }
