﻿/* AgroSIG - Estilos principales */

/* Variables y configuración global */
:root {
  --primary-color: #10b981; /* Verde esmeralda */
  --primary-dark: #059669;
  --primary-light: #34d399;
  --secondary-color: #3b82f6; /* Azul */
  --accent-color: #f59e0b; /* Ámbar */
  --danger-color: #ef4444; /* Rojo */
  --success-color: #22c55e; /* Verde */
  --warning-color: #f97316; /* Naranja */
  --info-color: #0ea5e9; /* Azul claro */
  
  --text-dark: #1f2937;
  --text-medium: #4b5563;
  --text-light: #9ca3af;
  --text-white: #ffffff;
  
  --bg-white: #ffffff;
  --bg-light: #f9fafb;
  --bg-medium: #f3f4f6;
  --bg-dark: #e5e7eb;
  
  --border-light: #e5e7eb;
  --border-medium: #d1d5db;
  --border-dark: #9ca3af;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 1rem;
  
  --header-height: 60px;
  --footer-height: 0px;
  --side-panel-width: 300px;
}

/* Reset y configuración base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #ffffff;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

ul, ol {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Header principal */
#main-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
  z-index: 1000;
}

.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.app-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-color);
}

#menu-toggle,
#layers-toggle,
#tools-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-dark);
  transition: background-color 0.2s ease;
}

#menu-toggle:hover,
#layers-toggle:hover,
#tools-toggle:hover {
  background-color: var(--bg-medium);
}

/* Pantalla de carga */
#splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-white);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  transition: opacity 0.5s ease;
}

.splash-content {
  text-align: center;
  padding: 2rem;
}

.splash-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 1rem;
  object-fit: contain;
}

.splash-content h1 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.splash-content p {
  color: var(--text-medium);
  margin-bottom: 1.5rem;
}

.loading-bar {
  width: 200px;
  height: 6px;
  background-color: var(--bg-medium);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin: 0 auto;
}

.loading-progress {
  height: 100%;
  width: 0%;
  background-color: var(--primary-color);
  transition: width 0.1s linear;
}

/* Menú lateral */
#side-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--side-panel-width);
  height: 100%;
  background-color: var(--bg-white);
  z-index: 200;
  box-shadow: var(--shadow-lg);
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

#side-menu.visible {
  transform: translateX(0);
}

.menu-header {
  display: flex;
  align-items: center;
  padding: 1rem;
  background-color: var(--primary-color);
  color: var(--text-white);
  position: relative;
}

.menu-logo {
  width: 40px;
  height: 40px;
  margin-right: 1rem;
  object-fit: contain;
}

.menu-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

#close-menu {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-white);
  transition: background-color 0.2s ease;
}

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

.menu-items {
  padding: 1rem 0;
}

.menu-items li.menu-section {
  padding: 0.9rem 1.5rem 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-color);
}

.menu-items li a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--text-dark);
  transition: background-color 0.2s ease;
}

.menu-items li a:hover {
  background-color: var(--bg-light);
}

.menu-items li a i {
  margin-right: 1rem;
  width: 20px;
  text-align: center;
  color: var(--primary-color);
}

/* Paneles laterales */
.side-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  width: var(--side-panel-width);
  height: calc(100% - var(--header-height));
  background-color: var(--bg-white);
  z-index: 150;
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
}

.side-panel.visible {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.panel-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-dark);
}

.close-panel {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-medium);
  transition: background-color 0.2s ease;
}

.close-panel:hover {
  background-color: var(--bg-light);
}

.panel-content {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
}

/* Capas */
.layer-list {
  margin-bottom: 1rem;
}

.empty-state {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-light);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.add-layer-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: var(--text-white);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: background-color 0.2s ease;
}

.add-layer-btn:hover {
  background-color: var(--primary-dark);
}

.add-layer-btn i {
  margin-right: 0.5rem;
}

/* Herramientas */
.tools-group {
  margin-bottom: 1.5rem;
}

.tools-group h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-medium);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tool-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--bg-light);
  color: var(--text-dark);
  transition: all 0.2s ease;
  border: 1px solid var(--border-light);
}

.tool-btn:hover {
  background-color: var(--bg-medium);
}

.tool-btn.active {
  background-color: var(--primary-color);
  color: var(--text-white);
  border-color: var(--primary-color);
}

/* Contenedor del mapa */
#map-container {
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100% - var(--header-height) - var(--footer-height));
  z-index: 50;
}

#map {
  width: 100%;
  height: 100%;
  background-color: #f0f0f0;
}

/* Controles de zoom */
.zoom-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
}

.zoom-controls button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg-white);
  color: var(--text-dark);
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: var(--shadow-md);
  transition: all 0.2s ease;
}

.zoom-controls button:hover {
  background-color: var(--bg-light);
}

/* Indicador de coordenadas */
#coordinates-display {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background-color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  z-index: 60;
}

#coordinates-display span {
  margin-right: 1rem;
}

#coordinates-display span:last-child {
  margin-right: 0;
}

/* Modales */
#modal-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#modal-container.visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  width: 90%;
  max-width: 500px;
  background-color: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.9);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal.visible {
  transform: scale(1);
  opacity: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-dark);
}

.close-modal {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-medium);
  transition: background-color 0.2s ease;
}

.close-modal:hover {
  background-color: var(--bg-light);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
}

/* Formularios */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-dark);
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background-color: var(--bg-white);
  color: var(--text-dark);
  transition: border-color 0.2s ease;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

/* Botones */
.primary-btn,
.secondary-btn {
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all 0.2s ease;
}

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

.primary-btn:hover {
  background-color: var(--primary-dark);
}

.primary-btn:disabled {
  background-color: var(--text-light);
  cursor: not-allowed;
}

.secondary-btn {
  background-color: var(--bg-light);
  color: var(--text-dark);
  border: 1px solid var(--border-medium);
}

.secondary-btn:hover {
  background-color: var(--bg-medium);
}

/* Input de archivo personalizado */
.file-input-container {
  margin: 1.5rem 0;
}

input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.file-input-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-md);
  background-color: var(--bg-light);
  cursor: pointer;
  transition: all 0.2s ease;
}

.file-input-label:hover {
  border-color: var(--primary-color);
  background-color: rgba(16, 185, 129, 0.05);
}

.file-input-label i {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 1rem;
}

#file-details {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--bg-light);
  border-radius: var(--radius-md);
}

/* Animaciones */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.6s ease-out;
}

/* Mejoras de accesibilidad */
input:focus,
textarea:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Transiciones suaves globales */
* {
    transition: all 0.3s ease;
}

/* Utilidades */
.hidden {
    display: none !important;
}

/* Submenú Hato */
.hato-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    white-space: nowrap;
}
.hato-toggle:hover {
    background: #f0fdf4;
    border-color: #10b981;
}
.hato-toggle.active {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}
.hato-toggle .fa-chevron-down {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}
.hato-toggle.open .fa-chevron-down {
    transform: rotate(180deg);
}
.hato-submenu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    padding: 0.6rem 0.1rem 0.9rem;
    margin-bottom: 0.25rem;
}
.hato-submenu a {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    color: #374151;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}
.hato-submenu a:hover {
    background: #f0fdf4;
    border-color: #10b981;
    color: #10b981;
}
.hato-submenu a.active {
    background: #10b981;
    border-color: #10b981;
    color: #ffffff;
}

/* Marcadores de punto */
.point-marker-wrap {
    background: transparent;
    border: none;
}

.point-marker {
    width: 30px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 14px;
    clip-path: polygon(50% 0%, 100% 0%, 100% 72%, 50% 100%, 0% 72%, 0% 0%);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.point-marker i {
    margin-top: -12px;
}

/* Puntos de dibujo temporal */
.drawing-point {
    background-color: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* Marcador del rebaño en el mapa */
.rebaño-marker {
    background: transparent;
    border: none;
}

/* Pantalla de sin acceso */
#sin-acceso {
    position: absolute;
    inset: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.94);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.sin-acceso-card {
    max-width: 380px;
    width: 100%;
    text-align: center;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 2rem 1.5rem;
}

.sin-acceso-icono {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #fee2e2;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
}

.sin-acceso-card h2 {
    color: #1f2937;
    font-size: 1.25rem;
    margin: 0 0 0.5rem;
}

.sin-acceso-card p {
    color: #6b7280;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 1.25rem;
}

.sin-acceso-btn {
    display: block;
    width: 100%;
    padding: 0.8rem;
    margin-bottom: 0.5rem;
    border: none;
    border-radius: 0.75rem;
    background: #10b981;
    color: #ffffff;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.sin-acceso-btn:hover {
    background: #059669;
}

.sin-acceso-btn.secundario {
    background: #ffffff;
    color: #ef4444;
    border: 1px solid #ef4444;
}

.sin-acceso-btn.secundario:hover {
    background: #fef2f2;
}

/* Marcador de ubicación */
.location-marker {
    background: transparent;
    border: none;
}

.location-marker-inner {
    width: 16px;
    height: 16px;
    background-color: #4a90e2;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(74, 144, 226, 0.8);
}

/* Selector de finca (cabecera) */
.finca-switcher {
  position: relative;
}

.finca-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  max-width: 190px;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  background-color: var(--bg-white);
  color: var(--text-dark);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.finca-switcher-btn:hover {
  background-color: var(--bg-light);
}

.finca-switcher-btn > i:first-child {
  color: var(--primary-color);
}

.finca-switcher-btn .finca-switcher-name {
  flex: 1;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.finca-switcher-btn .finca-switcher-arrow {
  font-size: 0.7rem;
  color: var(--text-light);
  transition: transform 0.2s ease;
}

.finca-switcher-btn.open .finca-switcher-arrow {
  transform: rotate(180deg);
}

.finca-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  max-height: 280px;
  overflow-y: auto;
  background-color: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 0.25rem;
  z-index: 1200;
}

.finca-switcher-menu li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dark);
  font-size: 0.9rem;
}

.finca-switcher-menu li:hover {
  background-color: var(--bg-medium);
}

.finca-switcher-menu li.active {
  background-color: #d1fae5;
  color: var(--primary-dark);
  font-weight: 600;
}

.finca-switcher-menu li > i {
  width: 1rem;
  color: var(--primary-color);
}

.finca-switcher-menu li.finca-switcher-empty {
  justify-content: center;
  color: var(--text-light);
  cursor: default;
}

.finca-switcher-menu li.finca-switcher-empty:hover {
  background-color: transparent;
}

/* Bloque de usuario en el menú lateral */
.menu-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  margin: 0 0.75rem 0.5rem;
  background: var(--bg-light);
  border-radius: var(--radius-md);
}

.menu-user-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary-color);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.menu-user-info {
  min-width: 0;
}

.menu-user-name {
  display: block;
  font-weight: 600;
  color: var(--text-dark);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.menu-user-email {
  display: block;
  color: var(--text-medium);
  font-size: 0.75rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}