/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    --primary: #4CAF50;
    --secondary: #012346;
    --accent: #2196F3;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Roboto', sans-serif;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-areas:
        "header header"
        "sidebar main";
    grid-template-columns: 250px 1fr;
    grid-template-rows: 70px 1fr;
    height: 100vh;
    overflow: hidden;
    background: #ecf0f1;
}

/* ============================================
   MEJORAS PARA RESULTADOS HSP
   ============================================ */

.hsp-month-card {
    transition: all 0.3s ease;
    cursor: default;
}

.hsp-month-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15) !important;
}

.hsp-month-card.minimum {
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 4px 12px rgba(255, 152, 0, 0.2);
    }

    50% {
        box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4);
    }
}

/* Responsive para móviles */
@media (max-width: 768px) {
    .hsp-month-card {
        padding: 12px !important;
    }

    .hsp-month-card div:nth-child(2) {
        font-size: 1.5em !important;
    }
}




/* ============================================
   HEADER
   ============================================ */
.dashboard-header {
    grid-area: header;
    background: linear-gradient(135deg, #2c3e50, #34495e);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.5em;
    font-weight: 700;
}

.logo i {
    color: var(--primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.project-name input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    width: 250px;
    font-size: 1rem;
}

.project-name input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.user-menu {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.user-menu:hover {
    transform: scale(1.1);
}

.user-menu i {
    font-size: 1.5em;
}

/* ============================================
   SIDEBAR
   ============================================ */
.dashboard-sidebar {
    grid-area: sidebar;
    background: #34495e;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 30px;
    overflow-y: auto;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 0 10px;
}

.nav-item {
    background: transparent;
    border: none;
    color: #ecf0f1;
    padding: 15px 20px;
    text-align: left;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1em;
    position: relative;
}

.nav-item i {
    font-size: 1.3em;
    width: 25px;
}

.nav-item:hover {
    background: rgba(52, 152, 219, 0.2);
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

.status-badge {
    margin-left: auto;
    font-size: 1.5em;
    color: #95a5a6;
}

.sidebar-stats {
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.mini-stat {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    color: #ecf0f1;
}

.mini-stat i {
    font-size: 1.8em;
    color: var(--primary);
}

.mini-stat strong {
    font-size: 1.2em;
    display: block;
}

.mini-stat small {
    font-size: 0.85em;
    color: #bdc3c7;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.dashboard-main {
    grid-area: main;
    overflow-y: auto;
    background: #ecf0f1;
    padding: 30px;
}

.dashboard-content {
    display: none;
    animation: fadeIn 0.5s;
}

.dashboard-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    color: var(--dark);
    font-size: 2em;
    margin-bottom: 10px;
}

.page-header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

/* ============================================
   SECTIONS
   ============================================ */
.section {
    margin-bottom: 40px;
    padding: 25px;
    background: white;
    border-radius: 10px;
    border-left: 5px solid var(--primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section h2 {
    color: var(--secondary);
    margin-bottom: 20px;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section h3 {
    color: var(--secondary);
    margin-bottom: 15px;
    font-size: 1.3em;
    margin-top: 20px;
}

/* ============================================
   FORMS
   ============================================ */
.input-group {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
}

.input-group label {
    flex: 1 1 200px;
    font-weight: 500;
    color: #555555;
}

.input-group input,
.input-group select {
    flex: 2 1 250px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dark);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: var(--primary);
}

.btn-secondary {
    background: var(--secondary);
}

.btn-accent {
    background: var(--accent);
}

.btn-danger {
    background: var(--danger);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* ============================================
   TABLES
   ============================================ */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

table th {
    background: var(--dark);
    color: white;
    padding: 15px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
}

table td {
    padding: 12px 15px;
    border-bottom: 1px solid #ecf0f1;
}

table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

table tbody tr:hover {
    background: #e8f4fc;
}

/* ============================================
   CARDS
   ============================================ */
.input-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.panel-selector-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.panel-selector-card h3 {
    color: white;
    margin-bottom: 20px;
}

.battery-config-card {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;
    box-shadow: 0 8px 20px rgba(17, 153, 142, 0.3);
}

.battery-config-card h3 {
    color: white;
    margin-bottom: 20px;
}

.battery-config-card label {
    color: white;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    border-top: 4px solid var(--primary);
    transition: all 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.stat-card .number {
    font-size: 2.5em;
    font-weight: bold;
    color: var(--primary);
    margin-bottom: 5px;
}

.stat-card .label {
    color: #666;
    font-size: 0.9em;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.alert-warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.alert-success {
    background: #d4edda;
    border: 1px solid #28a745;
    color: #155724;
}

.alert-danger {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ============================================
   CANVAS Y MAPPING - ✅ FULL-WIDTH PARA MÁS ESPACIO
   ============================================ */

/* Controles superiores en línea horizontal */
.sembrado-controls-top {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    gap: 15px;
    margin-bottom: 20px;
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.control-card {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e0e0e0;
}

.control-card h3 {
    color: var(--secondary);
    font-size: 0.9em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    font-weight: 700;
}

.control-compact {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.control-compact label {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
}

.control-compact strong {
    color: var(--primary);
    font-size: 1.1em;
}

.controls-inline {
    display: flex;
    gap: 15px;
}

.input-inline {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-inline label {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
}

.input-inline input,
.form-control-compact {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.95em;
    min-width: 100px;
}

.action-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
    background: transparent;
    border: none;
    padding: 0;
}

.btn-large {
    padding: 10px 20px;
    font-size: 0.9em;
    white-space: nowrap;
}

/* Estadísticas horizontales */
.stats-horizontal {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stats-horizontal .stat-item {
    background: white;
    padding: 15px 12px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e0e0e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
}

.stats-horizontal .stat-item:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stats-horizontal .stat-item i {
    font-size: 1.8em;
    color: var(--primary);
    display: block;
    margin-bottom: 8px;
}

.stats-horizontal .stat-item small {
    display: block;
    color: #666;
    font-size: 0.8em;
    margin-bottom: 5px;
    font-weight: 600;
}

.stats-horizontal .stat-item strong {
    display: block;
    font-size: 1.6em;
    color: var(--dark);
    font-weight: 700;
}

/* Canvas full-width */
.canvas-fullwidth {
    position: relative;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 400px);
    /* ✅ Ocupa todo el espacio disponible */
    min-height: 600px;
    /* ✅ Altura mínima */
}

.canvas-fullwidth #canvas-dibujo {
    display: block;
    cursor: crosshair;
    width: 100%;
    height: 100%;
}

.canvas-fullwidth #canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    text-align: center;
    pointer-events: none;
}

/* Mantener toolbars del canvas */
.canvas-fullwidth .map-toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    z-index: 100;
}

.canvas-fullwidth .zoom-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 100;
}

/* Layout antiguo (por si se necesita) */
.mapping-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 15px;
    height: calc(100vh - 150px);
    min-height: 650px;
}

.map-container {
    position: relative;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    min-height: 650px;
    height: 100%;
}

#canvas-dibujo {
    display: block;
    cursor: crosshair;
    width: 100%;
    height: 100%;
    min-height: 650px;
}

#canvas-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #888;
    text-align: center;
    pointer-events: none;
}

.map-toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    background: white;
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 10px;
    z-index: 100;
}

.tool-btn {
    background: white;
    border: 2px solid #ddd;
    padding: 10px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.tool-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.tool-btn.danger:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.zoom-indicator {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 15px;
    border-radius: 5px;
    font-size: 0.9rem;
    font-weight: 600;
    z-index: 100;
}

.map-sidebar {
    background: white;
    border-radius: 10px;
    padding: 15px;
    overflow-y: auto;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.control-section {
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 15px;
}

.control-section:last-child {
    border-bottom: none;
}

.control-section h3 {
    color: var(--secondary);
    font-size: 1.1em;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-section h4 {
    color: var(--secondary);
    font-size: 1em;
    margin-bottom: 10px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-compact {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 10px 0;
}

.stat-item {
    background: #f8f9fa;
    padding: 10px 8px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
}

.stat-item:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
}

.stat-item i {
    font-size: 1.5em;
    color: var(--primary);
    display: block;
    margin-bottom: 5px;
}

.stat-item small {
    display: block;
    color: #666;
    font-size: 0.75em;
    margin-bottom: 3px;
}

.stat-item strong {
    display: block;
    font-size: 1.3em;
    color: var(--dark);
}

/* ============================================
   INVERTER CARDS
   ============================================ */
.inverter-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.inverter-card:hover {
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.2);
    transform: translateY(-3px);
}

.inverter-card.selected {
    border-color: var(--primary);
    background: #f1f8f4;
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.3);
}

.inverter-card.recommended {
    border: 3px solid #ff9800;
    background: #fff8e1;
    position: relative;
}

.badge-recommended {
    position: absolute;
    top: -12px;
    left: 20px;
    background: #ff9800;
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.75em;
    font-weight: bold;
    letter-spacing: 0.5px;
}

/* ============================================
   TABS
   ============================================ */
.tab-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 2px solid #e0e0e0;
}

.tab-button {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #666;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1em;
}

.tab-button:hover {
    color: var(--primary);
    background: rgba(76, 175, 80, 0.05);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: rgba(76, 175, 80, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ============================================
   MATERIALS TABLE
   ============================================ */
.materials-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.materials-table th {
    background: var(--secondary);
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.materials-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
}

.materials-table tr.highlight {
    background: #f0f8ff;
    font-weight: 600;
}

.materials-table tbody tr:hover {
    background: #f8f9fa;
}

/* ============================================
   SUMMARY CARDS
   ============================================ */
.summary-card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.1);
    border-top: 5px solid var(--primary);
}

.summary-card h3 {
    color: var(--secondary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.result-summary-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.results-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin-top: 20px;
}

/* ============================================
   LOADING
   ============================================ */
#loading-hsp {
    text-align: center;
    padding: 20px;
    color: #666;
    animation: pulse 1.5s infinite;
}

/* ============================================
   SCROLLBARS
   ============================================ */
.dashboard-sidebar::-webkit-scrollbar,
.map-sidebar::-webkit-scrollbar,
.dashboard-main::-webkit-scrollbar {
    width: 8px;
}

.dashboard-sidebar::-webkit-scrollbar-track,
.map-sidebar::-webkit-scrollbar-track,
.dashboard-main::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

.dashboard-sidebar::-webkit-scrollbar-thumb,
.map-sidebar::-webkit-scrollbar-thumb,
.dashboard-main::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    body {
        grid-template-columns: 80px 1fr;
    }

    .nav-item span:not(.status-badge) {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 15px 10px;
    }

    .sidebar-stats {
        display: none;
    }

    .logo span {
        display: none;
    }

    .project-name {
        display: none;
    }
}

@media (max-width: 992px) {
    .mapping-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 500px auto;
        /* ✅ Canvas de 500px en móvil */
        height: auto;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    body {
        grid-template-areas:
            "header"
            "main";
        grid-template-columns: 1fr;
        grid-template-rows: 70px 1fr;
    }

    .dashboard-sidebar {
        display: none;
    }

    .dashboard-main {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-compact {
        grid-template-columns: 1fr;
    }

    .map-container {
        min-height: 400px;
        /* ✅ Altura mínima en móvil */
    }

    #canvas-dibujo {
        min-height: 400px;
    }
}

/* ============================================
   NOTIFICATION
   ============================================ */
.notification {
    position: fixed;
    top: 90px;
    right: 30px;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease-out;
}

.notification-success {
    background: var(--success);
    color: white;
}

.notification-error {
    background: var(--danger);
    color: white;
}

.notification-info {
    background: var(--info);
    color: white;
}

.notification-warning {
    background: var(--warning);
    color: white;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* ============================================
   HSP GRID COMPACTO
   ============================================ */
.hsp-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin: 20px 0;
}

.hsp-month-card-compact {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    transition: all 0.3s;
}

.hsp-month-card-compact:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.hsp-month-card-compact.minimum {
    border-color: #e74c3c;
    background: #ffebee;
    animation: pulse-glow 2s ease-in-out infinite;
    position: relative;
}

.hsp-month-badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #e74c3c;
    color: white;
    font-size: 0.65em;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(231, 76, 60, 0.3);
    animation: pulse-badge 1.5s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.hsp-month-code {
    font-weight: 700;
    color: #666;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.hsp-month-value {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 3px;
}

.hsp-month-unit {
    font-size: 0.7em;
    color: #999;
}

.hsp-summary-values {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-top: 20px;
}

.hsp-summary-values p {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hsp-summary-values strong {
    color: var(--secondary);
}

.hsp-summary-values span {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary);
}

/* ============================================ */
/* VISUALIZADOR 3D - ESTILOS */
/* ============================================ */

#visualizador-3d-root {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: row;
}

#tab-1\.5 {
    padding: 0;
    display: none;
    height: calc(100vh - 100px);
    width: 100%;
}

#tab-1\.5.active {
    display: block;
    height: calc(100vh - 100px);
    width: 100%;
    padding: 0;
    margin: 0;
}

/* ============================================
   VISUALIZADOR 3D - ESTILOS
   ============================================ */

/* Panel de controles 3D */
.controls-3d-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.control-3d-group {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary);
}

.control-3d-group h3 {
    color: var(--dark);
    margin-bottom: 15px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-3d-group h3 i {
    color: var(--primary);
}

/* Contenedor 3D */
#visualizador-3d-container {
    width: 100%;
    height: 600px;
    background: linear-gradient(to bottom, #87ceeb 0%, #e0f6ff 100%);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

#visualizador-3d-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Panel de estadísticas 3D */
.stats-3d-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.stat-3d-card {
    background: white;
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    border-top: 3px solid var(--primary);
}

.stat-3d-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.stat-3d-card i {
    font-size: 2em;
    color: var(--primary);
}

.stat-3d-card div {
    flex: 1;
}

.stat-3d-card small {
    display: block;
    color: #666;
    font-size: 0.85em;
    margin-bottom: 5px;
}

.stat-3d-card strong {
    display: block;
    font-size: 1.5em;
    color: var(--dark);
    font-weight: 700;
}

/* Sliders personalizados */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    opacity: 0.7;
    transition: opacity 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.slider:hover {
    opacity: 1;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Indicadores de string seleccionado */
.string-indicator {
    position: absolute;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 1000;
    animation: fadeInIndicator 0.3s;
}

@keyframes fadeInIndicator {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading 3D */
#loading-3d {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 100;
}

/* Responsive para visualizador 3D */
@media (max-width: 1024px) {
    .controls-3d-panel {
        grid-template-columns: 1fr;
    }

    #visualizador-3d-container {
        height: 500px;
    }
}

@media (max-width: 768px) {
    #visualizador-3d-container {
        height: 400px;
    }

    .stats-3d-panel {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================
   VISUALIZADOR 3D REACT
   ============================================ */

#visualizador-3d-react-root {
    width: 100%;
    height: calc(100vh - 100px);
    min-height: 600px;
    min-width: 800px;
    overflow: hidden;
    /* ✅ FIX: Asegurar que el contenedor siempre tenga dimensiones válidas */
    position: relative;
    display: flex;
    flex-direction: row;
}

#visualizador-3d-react-root>div {
    display: flex;
    height: 100%;
    width: 100%;
    min-height: inherit;
}

/* Sidebar del visualizador React */
#visualizador-3d-react-root .sidebar-3d {
    width: 320px;
    min-width: 320px;
    background: #1e293b;
    padding: 24px;
    overflow-y: auto;
    color: white;
}

/* Canvas container */
#visualizador-3d-react-root .canvas-3d-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, #87ceeb 0%, #a8d8ea 100%);
    min-width: 600px;
    min-height: 500px;
    /* ✅ FIX: Asegurar que Three.js pueda calcular dimensiones */
    width: 100%;
    height: 100%;
}

/* ✅ FIX: Asegurar que el canvas de Three.js ocupe todo el espacio */
#visualizador-3d-react-root canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

/* ============================================
   ESTILOS PARA SIDEBAR DE OBSTÁCULOS 3D
   ============================================ */

.sidebar-3d {
    position: fixed;
    top: 70px;
    left: 250px;
    width: 350px;
    height: calc(100vh - 70px);
    background: var(--dark);
    color: white;
    padding: 20px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-3d.hidden {
    transform: translateX(-100%);
}

.sidebar-section {
    margin-bottom: 25px;
}

.sidebar-section h3 {
    color: var(--accent);
    margin-bottom: 15px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.sidebar-section h4 {
    color: #fff;
    margin-bottom: 10px;
    font-size: 16px;
}

.obstacle-controls .form-group {
    margin-bottom: 15px;
}

.obstacle-controls label {
    display: block;
    margin-bottom: 5px;
    color: #ecf0f1;
    font-weight: 500;
}

.obstacle-controls input[type="range"] {
    width: 100%;
    margin-bottom: 8px;
}

.obstacle-list {
    margin-top: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.obstacle-item {
    background: rgba(255,255,255,0.1);
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.3s ease;
}

.obstacle-item:hover {
    background: rgba(255,255,255,0.2);
}

.obstacle-item.selected {
    background: var(--accent);
    border: 2px solid #60a5fa;
}

.obstacle-info {
    flex: 1;
}

.obstacle-info .obstacle-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.obstacle-info .obstacle-details {
    font-size: 12px;
    color: #cbd5e1;
}

.obstacle-actions {
    display: flex;
    gap: 5px;
}

.obstacle-actions button {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.shadow-analysis {
    background: rgba(220, 38, 38, 0.1);
    border: 2px solid #dc2626;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.shadow-info {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.shadow-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shadow-stat label {
    color: #fca5a5;
    font-size: 14px;
}

.shadow-stat span {
    font-weight: 600;
    color: #ef4444;
    font-size: 16px;
}

.time-controls {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid #22c55e;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.time-controls h4 {
    color: #4ade80;
    margin-bottom: 12px;
}

.time-controls .form-group {
    margin-bottom: 12px;
}

.time-controls label {
    color: #86efac;
    font-size: 13px;
}

.power-controls {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid #8b5cf6;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.power-controls h4 {
    color: #c4b5fd;
    margin-bottom: 12px;
}

.power-info {
    background: rgba(30, 41, 59, 0.8);
    padding: 12px;
    border-radius: 6px;
    margin-top: 12px;
    border: 1px solid #8b5cf6;
}

.power-info h5 {
    color: #a855f7;
    margin-bottom: 8px;
    font-size: 14px;
}

.power-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.power-stat label {
    color: #c4b5fd;
    font-size: 12px;
}

.power-stat span {
    font-weight: 600;
    color: #fbbf24;
    font-size: 13px;
}

.power-legend {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid rgba(139, 92, 246, 0.3);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.legend-item span {
    color: #e2e8f0;
    font-size: 11px;
}

.btn-toggle-sidebar {
    position: fixed;
    top: 80px;
    left: 10px;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .sidebar-3d {
        width: 300px;
    }
}

@media (max-width: 900px) {
    .sidebar-3d {
        position: absolute;
        width: 280px;
        transform: translateX(-100%);
    }
    
    .sidebar-3d.visible {
        transform: translateX(0);
    }
}

/* ============================================
   INDICADOR DE MODO DE OBSTÁCULOS
   ============================================ */
.obstacle-mode-indicator {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
    font-weight: 600;
    border: 2px solid;
    transition: all 0.3s ease;
}

.obstacle-mode-indicator.create-mode {
    background: rgba(34, 197, 94, 0.1);
    border-color: #22c55e;
    color: #4ade80;
}

.obstacle-mode-indicator.edit-mode {
    background: rgba(245, 158, 11, 0.1);
    border-color: #f59e0b;
    color: #fbbf24;
}

.mode-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

/* ============================================
   INDICADOR DE TIEMPO REAL
   ============================================ */
#realtime-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(139, 92, 246, 0.95);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    z-index: 1002;
    display: none;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.3);
    transition: all 0.3s ease;
}

#realtime-indicator i {
    margin-right: 5px;
}

/* ============================================
   BOTONES DE ACCIONES DE EDICIÓN
   ============================================ */
#edit-actions {
    display: none;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}

#edit-actions button {
    padding: 10px;
    border: none;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

#btn-save-obstacle {
    background: #22c55e;
}

#btn-save-obstacle:hover {
    background: #16a34a;
}

#btn-delete-selected {
    background: #ef4444;
}

#btn-delete-selected:hover {
    background: #dc2626;
}

#btn-cancel-edit {
    background: #6b7280;
}

#btn-cancel-edit:hover {
    background: #4b5563;
}

/* ============================================
   MEJORAS VISUALES ADICIONALES
   ============================================ */
.form-group input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.obstacle-item {
    transition: all 0.3s ease;
}

.obstacle-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.obstacle-item.selected {
    border-left: 4px solid #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}