/**
 * IRP Patrimonial - Layout CSS
 * Estructura principal de la aplicación
 */

/* ========================================
   APP CONTAINER
   ======================================== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* ========================================
   HEADER
   ======================================== */
#header {
  height: var(--header-height);
  min-height: var(--header-height);
  background: linear-gradient(180deg, var(--secondary-dark), var(--secondary));
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 15px;
  z-index: var(--z-header);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo img {
  height: 32px;
  width: auto;
  border-radius: 4px;
}

.header-logo-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

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

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

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

/* ========================================
   MAIN CONTENT AREA
   ======================================== */
#main-content {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ========================================
   MAP CONTAINER
   ======================================== */
#map-container {
  flex: 1;
  position: relative;
  z-index: var(--z-map);
}

#map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

/* ========================================
   PANEL BASE STYLES
   ======================================== */
.panel {
  width: var(--panel-width);
  min-width: var(--panel-width);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  z-index: var(--z-panels);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

.panel-left {
  border-right: 1px solid var(--border-color);
  order: -1;
}

.panel-right {
  border-left: 1px solid var(--border-color);
  width: auto !important;
  min-width: auto !important;
  flex-direction: row !important;
  overflow: visible !important;
}

.panel.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  max-width: 0 !important;
  overflow: hidden;
  border: none;
}

/* ========================================
   PANEL SPLITTERS (Resizable)
   ======================================== */
.panel-splitter {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  position: relative;
  z-index: calc(var(--z-panels) + 5);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.panel-splitter-left {
  order: 0;
}

.panel-splitter-right {
  order: 0;
}

.panel-splitter:hover,
.panel-splitter:active {
  background: rgba(250, 92, 0, 0.12);
}

.splitter-handle {
  width: 2px;
  height: 40px;
  background: var(--border-color);
  border-radius: 2px;
  transition: all var(--transition-fast);
  pointer-events: none;
}

.panel-splitter:hover .splitter-handle,
.panel-splitter:active .splitter-handle {
  background: var(--primary);
  height: 60px;
  width: 3px;
}

/* Ocultar splitters cuando panel está colapsado */
.panel.collapsed + .panel-splitter,
.panel-splitter + .panel.collapsed {
  display: none;
}

/* Cursor global durante resize */
body.resizing-panels {
  cursor: col-resize !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

body.resizing-panels * {
  cursor: col-resize !important;
  pointer-events: none !important;
}

body.resizing-panels .panel-splitter {
  pointer-events: auto !important;
  background: rgba(250, 92, 0, 0.15);
}

body.resizing-panels .panel-splitter .splitter-handle {
  background: var(--primary);
  height: 60px;
  width: 3px;
}

/* Panel izquierdo: vtabs-bar | tools-col | panel-elements en fila */
/* Los estilos de cada componente están en ribbon.css */

/* Panel Header */
.panel-header {
  height: var(--toolbar-height);
  min-height: var(--toolbar-height);
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 10px;
  flex-shrink: 0;
}

.panel-header-elements {
  background: var(--bg-darker);
}

.panel-header-icon {
  color: var(--primary);
  font-size: 16px;
  width: 16px;
  text-align: center;
}

.panel-header-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-header-actions {
  display: flex;
  gap: 4px;
}

/* Botón seleccionar todos en header de elementos */
#btn-select-all {
  margin-left: auto;
  opacity: 0.6;
  transition: all 0.2s;
}

#btn-select-all:hover {
  opacity: 1;
}

#btn-select-all.active {
  color: var(--primary);
  opacity: 1;
}

#btn-select-all.partial {
  color: var(--warning);
  opacity: 0.8;
}

/* Panel Content - scrollable */
.panel-content {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Elements List Container - crece según contenido, scrollea al llegar al límite */
.elements-list-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

#elements-list-content {
  padding: 4px 0;
}

#elements-list-content:empty {
  display: none;
}

.elements-list-container::-webkit-scrollbar {
  width: 6px;
}

.elements-list-container::-webkit-scrollbar-track {
  background: transparent;
}

.elements-list-container::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

/* Panel Section */
.panel-section {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.panel-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.panel-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.panel-section-title i {
  color: var(--primary);
  width: 14px;
  text-align: center;
  font-size: 11px;
}

/* ========================================
   STATUS BAR
   ======================================== */
#statusbar {
  height: var(--statusbar-height);
  min-height: var(--statusbar-height);
  background: var(--bg-dark);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 11px;
  color: var(--text-secondary);
  z-index: var(--z-statusbar);
}

.statusbar-left,
.statusbar-center,
.statusbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
}

.statusbar-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.statusbar-item i {
  font-size: 12px;
  color: var(--text-muted);
}

#coords-display {
  font-family: 'Consolas', monospace;
  font-size: 11px;
}

/* GPS activo - texto rojo */
#coords-display.gps-active {
  color: #f44336;
}

#coords-display.gps-active strong {
  color: #ff5252;
}

#coords-display.gps-active i {
  margin-right: 4px;
}

/* ========================================
   TOOLBAR (Barra inferior de herramientas)
   ======================================== */
#toolbar {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-dark);
  border-radius: var(--border-radius);
  padding: 6px;
  display: flex;
  gap: 4px;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-toolbar);
}

.toolbar-divider {
  width: 1px;
  background: var(--border-color);
  margin: 4px 4px;
}

/* ========================================
   FLOATING CONTROLS
   ======================================== */
.floating-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: var(--z-toolbar);
}

.floating-controls-group {
  background: var(--bg-dark);
  border-radius: var(--border-radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow-md);
}

/* ========================================
   UTM INPUT PANEL
   (Estilos movidos a components.css)
   ======================================== */

/* ========================================
   LAYER SWITCHER
   ======================================== */
#layer-switcher {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--bg-dark);
  border-radius: var(--border-radius);
  padding: 3px;
  display: flex;
  gap: 6px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
}

#mincul-switcher,
#riotinto-pdf-switcher {
  position: absolute;
  top: 6px;
  right: 46px;
  background: var(--bg-dark);
  border-radius: var(--border-radius);
  padding: 3px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#mincul-switcher.hidden,
#riotinto-pdf-switcher.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(10px);
}

/* Cuando hay panel derecho visible */
@media (min-width: 1025px) {
  #panel-right:not(.collapsed) ~ #map-container #layer-switcher {
    right: 10px;
  }
}

/* ========================================
   MOBILE TOGGLE BUTTONS (Edge-style, like desktop)
   ======================================== */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 70px;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 14px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.mobile-toggle:hover {
  background: var(--primary-dark);
}

.mobile-toggle:active {
  transform: translateY(-50%) scale(0.95);
}

.mobile-toggle-left {
  left: 0;
  border-radius: 0 8px 8px 0;
}

.mobile-toggle-right {
  right: 0;
  border-radius: 8px 0 0 8px;
}

/* ========================================
   SPLASH SCREEN
   ======================================== */
#splash {
  position: fixed;
  inset: 0;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-splash);
  opacity: 1;
  transition: opacity 1.2s ease-in-out;
}

#splash.fade-out {
  opacity: 0;
  pointer-events: none;
}

#splash img {
  width: 18vw;
  min-width: 80px;
  max-width: 280px;
  opacity: 0;
  transform: scale(0.6);
}

#splash img.animate {
  animation: splashDolly 3s ease-in-out forwards;
}

@keyframes splashDolly {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  25% {
    opacity: 1;
    transform: scale(0.85);
  }
  55% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

/* Fallback: animaciones desactivadas en el SO */
@media (prefers-reduced-motion: reduce) {
  #splash img.animate {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
  #splash.fade-out img {
    opacity: 0 !important;
    transition: opacity 0.8s ease;
  }
}

/* ========================================
   PANEL EXPAND BUTTONS (Desktop)
   ======================================== */
.panel-expand-btn {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 70px;
  background: var(--primary);
  border: none;
  color: white;
  cursor: pointer;
  z-index: calc(var(--z-panels) + 10);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-lg);
}

.panel-expand-btn:hover {
  background: var(--primary-hover);
  width: 35px;
}

.panel-expand-left {
  left: 0;
  border-radius: 0 8px 8px 0;
}

.panel-expand-right {
  right: 0;
  border-radius: 8px 0 0 8px;
}

.panel-expand-btn.hidden {
  display: none !important;
}

/* Tooltip para tooltips polticos */
.political-tooltip {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  padding: 6px 10px !important;
  border-radius: var(--border-radius) !important;
  font-size: 12px !important;
  box-shadow: var(--shadow-md) !important;
}
