/* css/base.css */

/* =========================
   Global Reset & Variables
   ========================= */
:root {
  --bg: #f8fafc;
  /* Slate-50 */
  --bg-deep: #f1f5f9;
  /* Slate-100 */
  --text: #0f172a;
  /* Slate-900 */
  --primary: #4f46e5;
  /* Indigo-600 */

  --topbar-h: 64px;
  /* En escritorio la barra superior no se muestra (ver #topbar en
     index.html), asi que los calc(100svh - var(--topbar-h)) de los modulos
     a pantalla completa deben descontar 0. */
  --cfg-gutter: 24px;
  --cfg-gutter-md: 32px;
}

@media (min-width: 768px) {
  :root {
    --topbar-h: 0px;
  }
}

html.dark {
  --bg: #0f172a;
  /* Slate-900 */
  --bg-deep: #020617;
  /* Slate-950 */
  --text: #f8fafc;
  /* Slate-50 */
}

/* =========================
   Glassmorphism Utility
   ========================= */
.glass {
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

html.dark .glass {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}


* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* =========================
   Premium Scrollbars
   ========================= */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #334155;
  /* Slate-700 */
  border-radius: 99px;
  transition: background 0.2s;
}

::-webkit-scrollbar-thumb:hover {
  background: #475569;
  /* Slate-600 */
}

/* Sidebar specific scroll */
.sidebar-scroll::-webkit-scrollbar {
  width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
  background: #1e293b;
  /* Slate-800 */
}

/* =========================
   Animations & Transitions
   ========================= */
.sidebar-transition {
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease-in-out;
}

.collapsible-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.collapsible-wrapper.expanded {
  grid-template-rows: 1fr;
}

.collapsible-inner {
  overflow: hidden;
}

/* Sidebar submenu visual polish */
.item-with-submenu > .sidebar-item {
  border: 1px solid transparent;
}

.item-with-submenu > .sidebar-item:hover {
  border-color: rgba(148, 163, 184, 0.22);
}

.nav-subitem {
  display: flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

.nav-subitem:hover {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.2);
}

.nav-subitem.text-white {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(59, 130, 246, 0.35));
  border-color: rgba(129, 140, 248, 0.45);
  box-shadow: 0 8px 14px rgba(37, 99, 235, 0.2);
}

.rotate-180 {
  transform: rotate(180deg);
}

/* =========================
   Layout Utilities
   ========================= */
/* Fullscreen handlers */
body.is-fullscreen #sidebar {
  transform: translateX(-100%);
  position: absolute;
}

body.is-fullscreen #topbar {
  transform: translateY(-100%);
  opacity: 0;
  height: 0;
}

body.is-fullscreen #sidebarOverlay {
  display: none !important;
}

@media (max-width: 767px) {
  #btnFullscreen {
    display: none !important;
  }
}

/* Desktop Collapsed Sidebar */
@media (min-width: 768px) {
  .sidebar-collapsed {
    width: 80px !important;
  }

  .sidebar-collapsed .sidebar-text,
  .sidebar-collapsed .sidebar-section-title,
  .sidebar-collapsed .sidebar-footer-info,
  .sidebar-collapsed .submenu-toggle,
  .sidebar-collapsed .chevron-icon {
    display: none !important;
  }

  .sidebar-collapsed .item-with-submenu .collapsible-wrapper {
    display: none !important;
  }

  .sidebar-collapsed .sidebar-item {
    justify-content: center !important;
    padding: 0 !important;
    margin: 0 auto;
    width: 48px;
    height: 48px;
  }

  .sidebar-collapsed .nav-content-btn {
    justify-content: center !important;
    width: 100%;
    margin: 0 !important;
  }
}

/* =========================
   Dynamic Content Area
   ========================= */
#mainContent {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  background-color: var(--bg-deep);
  /* Subtle background pattern for premium feel */
  background-image:
    radial-gradient(at 0% 0%, rgba(79, 70, 229, 0.03) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.03) 0px, transparent 50%);
  color: inherit;
}

#dynamicSections {
  position: relative;
  min-height: 400px;
}

/* Full Bleed Modulos (Monitoreo, Video, etc) */
body.module-monitoreo #mainContent,
body.module-recorrido #mainContent,
body.module-video #mainContent,
body.module-videoteca #mainContent,
body.module-plan_servicio #mainContent,
body.module-acreditacion #mainContent,
body.module-resumen_utilizacion #mainContent,
body.module-utilizacion_flota #mainContent {
  padding: 0 !important;
  overflow: hidden !important;
}

/* Dynamic height calculation for full bleed */
body.module-monitoreo #dynamicSections,
body.module-recorrido #dynamicSections,
body.module-video #dynamicSections,
body.module-videoteca #dynamicSections,
body.module-plan_servicio #dynamicSections,
body.module-acreditacion #dynamicSections,
body.module-resumen_utilizacion #dynamicSections,
body.module-utilizacion_flota #dynamicSections {
  height: calc(100svh - var(--topbar-h)) !important;
  min-height: calc(100svh - var(--topbar-h)) !important;
  padding: 0 !important;
  background: transparent !important;
  overflow: hidden !important;
  display: block !important;
}

/* Config: Gutter */
body.module-configuracion #dynamicSections {
  padding: var(--cfg-gutter) !important;
}

@media (min-width: 768px) {
  body.module-configuracion #dynamicSections {
    padding: var(--cfg-gutter-md) !important;
  }
}

/* Public Layout */
body.public-auth {
  overflow: hidden;
}

body.public-auth #sidebar,
body.public-auth #notificationSidebar,
body.public-auth #sidebarOverlay,
body.public-auth #btnFullscreen,
body.public-auth #topbar {
  display: none !important;
}

body.public-auth #mainContent {
  padding: 0 !important;
  overflow: hidden !important;
}

body.public-auth #dynamicSections {
  height: 100svh !important;
  min-height: 100svh !important;
  padding: 0 !important;
  background: transparent !important;
}

/* =========================
   Utility Animations
   ========================= */
.animate-fade-in {
  animation: fadeIn 0.4s ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 0.5s ease-out forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(15px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
