/* ===== GLOBAL SITE STYLES ===== */

/* Import base dashboard variables */
@import url("./dashboard.css");


:root {
    --header-height: 64px;
    --footer-height: 17px;
    /* Windows 11-like scrollbar palette */

    --scrollbar-thumb: rgba(148, 163, 184, 0.45);
    --scrollbar-thumb-hover: rgba(148, 163, 184, 0.75);
    --scrollbar-track: transparent;
}


/* Leaflet trip-stop popup: remove outer default frame so only our
   custom card markup is visible. */
.trip-stop-popup .leaflet-popup-content-wrapper {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  border: none;
}

.trip-stop-popup .leaflet-popup-content {
  margin: 0;
}

.trip-stop-popup .leaflet-popup-tip-container,
.trip-stop-popup .leaflet-popup-tip {
  display: none;
}

/* ===== MAIN LAYOUT ===== */
.page {
  position: relative;
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

.sidebar {
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  z-index: 100;
}

.top-row {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
  z-index: 50;
}

.app-title h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 16px;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
}

.theme-toggle .btn-theme {
  padding: 8px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.theme-toggle .btn-theme:hover {
  background: var(--dashboard-bg);
  color: var(--accent-blue);
}

.content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ===== UTILITY CLASSES ===== */
.px-4 {
  padding-left: 24px;
  padding-right: 24px;
}

.text-center {
  text-align: center;
}

.text-primary {
  color: var(--text-primary);
}

.text-secondary {
  color: var(--text-secondary);
}

.bg-primary {
  background: var(--accent-blue);
}

.bg-secondary {
  background: var(--dashboard-bg);
}

/* ===== LOADING STATES ===== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading::after {
  content: "";
  width: 24px;
  height: 24px;
  border: 2px solid var(--panel-border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-left: 12px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== ERROR HANDLING ===== */
#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;
}

/* Header Component Styles */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: var(--header-height);
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border-bottom: 1px solid #334155;
  padding: 0 16px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

/* Header Left Section */
.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.hamburger-menu {
  background: none;
  border: none;
  color: #e2e8f0;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hamburger-menu:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.hamburger-icon {
  width: 20px;
  height: 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.hamburger-icon span {
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: all 0.3s ease;
}

/* Logo Section */
.logo-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  height: 32px;
  width: auto;
}

.app-name {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: -0.025em;
}

.pulse-indicator {
  color: #10b981;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Header Right Section */
.header-right {
  display: flex;
  align-items: center;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inline host for dashboard actions, sits just left of the notification bell */
.dashboard-actions-host {
  display: flex;
  align-items: center;
  margin-right: 8px;
}

/* When the toolbar is placed inside the header host, force inline positioning */
.dashboard-actions-host .dashboard-floating-controls {
  position: static !important;
  top: auto !important;
  right: auto !important;
  left: auto !important;
}

/* Header Buttons */
.header-btn {
  background: none;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

/* Notification Button */
.notification-btn {
  position: relative;
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* User Profile Section */
.user-profile-section {
  position: relative;
  margin-left: 8px;
}

.user-profile-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-profile-btn:hover {
  transform: scale(1.05);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #475569;
}

.user-initials {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  border: 2px solid #475569;
}

/* User Dropdown */
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  min-width: 220px;
  z-index: 1001;
  overflow: hidden;
}

.user-info {
  padding: 16px;
  border-bottom: 1px solid #334155;
}

.user-name {
  font-weight: 600;
  color: #ffffff;
  font-size: 14px;
  margin-bottom: 4px;
}

.user-role {
  color: #94a3b8;
  font-size: 12px;
}

.dropdown-divider {
  border: none;
  border-top: 1px solid #334155;
  margin: 0;
}

.dropdown-item {
  width: 100%;
  background: none;
  border: none;
  color: #e2e8f0;
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #ffffff;
}

.dropdown-item.logout {
  color: #f87171;
  border-top: 1px solid #334155;
}

.dropdown-item.logout:hover {
  background: rgba(248, 113, 113, 0.1);
  color: #fca5a5;
}

/* App Layout */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-container {
  display: flex;
  flex: 1;
  min-height: 0; /* allow content-area to size and scroll internally */
}

.sidebar {
  background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  transition: all 0.25s ease;
  border-right: 1px solid #334155;
  overflow: hidden; /* prevent sidebar from creating page-level scroll */
}

/* Three modes: wide, narrow, hidden */
.sidebar-wide {
  width: 250px;
  overflow: auto; /* internal scroll if menu is long */
}

.sidebar-narrow {
  width: 72px;
  overflow: hidden; /* keep rail from adding scrollbars */
}

.sidebar-hidden {
  width: 0;
  border-right-color: transparent;
  overflow: hidden; /* fully collapse */
}

/* Left navigation links container */
.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 100vh; /* never exceed viewport height */
  overflow-y: auto; /* scroll inside menu, not page */
}

/* Inherit sidebar mode to NavMenu: when narrow, hide texts and show tooltips */
.sidebar-narrow .nav-link span,
.sidebar-narrow .nav-section-title,
.sidebar-narrow .nav-logo span {
  display: none;
}

.sidebar-narrow .nav-link {
  justify-content: center;
  padding-left: 0;
  padding-right: 0;
}

.sidebar-narrow .nav-logo i {
  margin: 0 auto;
}

/* Custom tooltip for slim rail */
.sidebar-narrow .nav-link {
  position: relative;
}

.sidebar-narrow .nav-link:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: #111827;
  color: #e5e7eb;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  margin-left: 12px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  pointer-events: none;
}

.sidebar-narrow .nav-link:hover::before {
  content: "";
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: transparent transparent transparent #111827;
  z-index: 10000;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    /*background: #f8fafc;*/
    background: #0f172a;
    color: #e2e8f0;
    min-height: 0; /* allow page-content to manage scroll */
    height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow: hidden;
}

.page-content {
    flex: 1;
    padding: 2px; /* minimal padding on all sides */
    overflow: hidden; /* inner pages handle their own scroll */
    height: 100%;
    background: #0f172a;
}

/* Generic form section styling used across pages (modal forms and preferences) */
.form-section {
    /*  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.2);*/
    background: rgba(255, 255, 255, 0.05);
    border:1px solid rgba(148, 163, 184, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin: 12px;
}
.form-section .config-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  margin-top: 8px;
  overflow: hidden; /* prevent overlap with grid above */
}
/* Boost contrast in dark theme */
[data-theme="dark"] .form-section {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(148, 163, 184, 0.3);
}

/* ===== Windows 11-like slim scrollbars (global) ===== */
/* Firefox */
/** {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}*/

/* WebKit/Blink */
/**::-webkit-scrollbar {
  width: 8px;
  height: 8px;
  background: var(--scrollbar-track);
}
*::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
*::-webkit-scrollbar-thumb {
  background-color: var(--scrollbar-thumb);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--scrollbar-thumb-hover);
}
*::-webkit-scrollbar-corner {
  background: var(--scrollbar-track);
}*/

/* Show subtle arrows only on hover over the scrollable area */
/* Hide legacy arrow buttons entirely (modern Windows style does not show them) */
*::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  background: transparent !important;
}
*::-webkit-scrollbar-button:single-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
*::-webkit-scrollbar-button:start:decrement,
*::-webkit-scrollbar-button:end:increment,
*::-webkit-scrollbar-button:horizontal:decrement,
*::-webkit-scrollbar-button:horizontal:increment,
*::-webkit-scrollbar-button:vertical:decrement,
*::-webkit-scrollbar-button:vertical:increment {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}
*::-webkit-scrollbar-button {
  -webkit-appearance: none !important;
}

/* Extra-aggressive targeting to suppress any UA/overlay buttons */
html::-webkit-scrollbar-button,
body::-webkit-scrollbar-button,
.content-area::-webkit-scrollbar-button,
.page-content::-webkit-scrollbar-button,
.dashboard-grid::-webkit-scrollbar-button,
.dashboard-panel::-webkit-scrollbar-button,
.orders-shipments-panel::-webkit-scrollbar-button,
.orders-shipments-panel *::-webkit-scrollbar-button,
.modal-content::-webkit-scrollbar-button,
.list-box::-webkit-scrollbar-button {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Slightly emphasize the bar on hover */
/**:hover::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}*/

/* Dark Theme */
[data-theme="dark"] .content-area {
  background: #0f172a;
  color: #e2e8f0;
}

[data-theme="dark"] .page-content {
  background: #0f172a;
}

/* Keep dashboard control icons/text light in light mode as header stays dark */
[data-theme="light"] .dashboard-floating-controls .btn-mode,
[data-theme="light"] .dashboard-floating-controls .icon-btn {
  color: #e5e7eb;
}
[data-theme="light"] .dashboard-floating-controls .btn-mode.active {
  background: #3b82f6;
  color: #ffffff;
}
/* Remove light theme white outlines around toolbar group and icons */
[data-theme="light"] .dashboard-floating-controls .mode-toggle {
  border-color: transparent;
}
[data-theme="light"] .dashboard-floating-controls.design .icon-btn,
[data-theme="light"] .dashboard-floating-controls.view .icon-btn {
  border-color: transparent;
}

/* keep sidebar and footer dark in both themes */
[data-theme="light"] .sidebar,
[data-theme="dark"] .sidebar, .sidebar {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
}

[data-theme="light"] .app-footer,
[data-theme="dark"] .app-footer, .app-footer {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border-top: 0; /* keep visual height exact */
}

/* NavMenu Responsive Styles */
@media (max-width: 768px) {
  .nav-menu {
    width: 200px;
  }

  .nav-link span {
    display: none;
  }

  .nav-link {
    justify-content: center;
    padding: 12px;
  }

  .nav-logo span {
    display: none;
  }

  .nav-section-title {
    display: none;
  }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  .page {
    flex-direction: column;
  }

  .sidebar {
    order: 2;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto;
    z-index: 1000;
  }

  main {
    order: 1;
    margin-bottom: 60px; /* Space for mobile nav */
  }

  .top-row {
    padding: 0 16px;
    height: 50px;
  }
  :root {
    --header-height: 50px;
  }

  .app-title h1 {
    font-size: 18px;
  }

  .px-4 {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 480px) {
  .user-menu {
    gap: 8px;
  }

  .user-name {
    display: none;
  }

  .theme-toggle .btn-theme {
    width: 32px;
    height: 32px;
  }
}

/* ===== FOCUS STYLES ===== */
.btn:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--accent-blue);
  outline-offset: 2px;
}

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar,
  .top-row {
    display: none;
  }

  main {
    margin: 0;
  }

  .content {
    padding: 0;
  }

  .dashboard-toolbar {
    display: none;
  }

  .panel-header .panel-controls {
    display: none;
  }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    :root {
        /*  --panel-border: #000000;
    --text-secondary: #000000;
    --dashboard-bg: #ffffff;
    --panel-bg: #ffffff;*/
        --panel-border: #ffffff;
        --text-secondary: #ffffff;
        --dashboard-bg: #000000;
        --panel-bg: #000000;
    }

  [data-theme="dark"] {
    --panel-border: #ffffff;
    --text-secondary: #ffffff;
    --dashboard-bg: #000000;
    --panel-bg: #000000;
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.ws-editor-overlay .h1, .ws-editor-overlay .h2, .ws-editor-overlay .h3, .ws-editor-overlay .h4, .ws-editor-overlay .h5, .ws-editor-overlay .h6, .ws-editor-overlay h1,
.ws-editor-overlay h2, .ws-editor-overlay h3, .ws-editor-overlay h4, .ws-editor-overlay h5, .ws-editor-overlay h6 {
    margin-top: 0;
    margin-bottom: .5rem;
    font-weight: 500;
    line-height: 1.2;
    color: var(--bs-heading-color);
}

.ws-editor-overlay div, .ws-editor-overlay p, .ws-editor-overlay label {
    margin-top: 0;
    margin-bottom: .5rem;
    font-weight: 400;
    line-height: 1.2;
    color: var(--bs-heading-color);
    font-size: 0.8rem;
}
