/* ========================================
   HONESTGREENS IoT PLATFORM
   Tema: Oscuro con verde corporativo
   ======================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #fff;
    padding: 20px;
}

header {
    background: #2d5016;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
}

header h1 {
    font-size: 1.8em;
    font-weight: 300;
}

.ciudad-section {
    margin-bottom: 40px;
}

.ciudad-title {
    background: #4a7c1f;
    padding: 15px 20px;
    font-size: 1.3em;
    font-weight: 500;
    margin-bottom: 20px;
    border-radius: 8px;
}

/* Estilos para colapso de ciudades */
.ciudad-toggle {
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
}

.ciudad-toggle:hover {
    background: linear-gradient(135deg, #5a8c2a 0%, #6a9c3a 100%);
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(74, 124, 31, 0.3);
}

.ciudad-toggle:active {
    transform: translateX(3px);
}

.toggle-icon {
    display: inline-block;
    width: 24px;
    font-size: 18px;
    transition: transform 0.3s ease;
    font-weight: bold;
}

.locales-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.local-card {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
}

.local-card:hover {
    background: #333;
    border-color: #4a7c1f;
    transform: translateY(-2px);
}

.local-card.functional {
    border-color: #4a7c1f;
    box-shadow: 0 0 15px rgba(74, 124, 31, 0.3);
}

.local-header {
    color: #7fb83e;
    font-size: 1.2em;
    font-weight: 500;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3a3a3a;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: 0.95em;
}

.info-label {
    color: #999;
}

.info-value {
    color: #fff;
    font-weight: 500;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.85em;
}

.status-online {
    background: #2d5016;
    color: #7fb83e;
}

.status-offline {
    background: #3a1a1a;
    color: #d9534f;
}

select {
    width: 100%;
    padding: 8px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 0.9em;
    cursor: pointer;
}

select:hover:not(:disabled) {
    border-color: #4a7c1f;
}

select:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.btn-action {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    background: linear-gradient(135deg, #3a6c1a 0%, #5a8c2a 100%);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.95em;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    text-align: center;
    box-shadow: 0 2px 6px rgba(58, 108, 26, 0.3);
}

.btn-action:hover:not(:disabled) {
    background: linear-gradient(135deg, #4a7c1f 0%, #6a9c3a 100%);
    box-shadow: 0 3px 10px rgba(58, 108, 26, 0.5);
    transform: translateY(-1px);
}

.btn-action:disabled {
    background: #3a3a3a;
    color: #666;
    cursor: not-allowed;
}

.btn-action.btn-secondary {
    background: linear-gradient(135deg, #2a4a14 0%, #3a5a24 100%);
    margin-top: 5px;
}

.btn-action.btn-secondary:hover {
    background: linear-gradient(135deg, #3a5a24 0%, #4a6a34 100%);
}

.admin-section {
    margin-top: 50px;
    padding: 30px;
    background: #2a2a2a;
    border-radius: 8px;
}

.admin-title {
    color: #7fb83e;
    font-size: 1.5em;
    margin-bottom: 20px;
}

.admin-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.admin-link {
    display: block;
    padding: 15px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #7fb83e;
    text-decoration: none;
    text-align: center;
    transition: all 0.3s ease;
}

.admin-link:hover {
    background: #4a7c1f;
    color: white;
    border-color: #4a7c1f;
}

/* ========================================
   PÁGINA DE LOCAL INDIVIDUAL
   ======================================== */
.back-link {
    display: inline-block;
    color: #7fb83e;
    text-decoration: none;
    font-size: 1rem;
    margin-bottom: 1rem;
    opacity: 0.9;
    transition: opacity 0.3s;
}

.back-link:hover {
    opacity: 1;
}

.local-controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.control-card {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 20px;
}

.control-card h3 {
    color: #7fb83e;
    margin-bottom: 15px;
}

.status-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.status-label {
    color: #999;
}

.status-value {
    font-weight: 600;
}

.status-value.online {
    color: #7fb83e;
}

.dashboards-section {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 20px;
}

.dashboards-section h2 {
    color: #7fb83e;
    margin-bottom: 20px;
}

.dashboard-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    color: #999;
}

.tab-btn:hover {
    background: #2a4a14;
    color: #fff;
    border-color: #4a7c1f;
}

.tab-btn.active {
    background: #4a7c1f;
    color: white;
    border-color: #5c9326;
}

.dashboard-container {
    position: relative;
}

.dashboard-frame {
    display: none;
}

.dashboard-frame.active {
    display: block;
}

.dashboard-frame iframe {
    border-radius: 8px;
    border: 1px solid #3a3a3a;
}

/* ========================================
   CALENDARIO DE MANTENIMIENTO NOCTURNO - ESTILO VERDE
   ======================================== */

.maintenance-section {
    margin-top: 20px;
    border-top: 1px solid #3a3a3a;
    padding-top: 16px;
}

.maintenance-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1f3d10 0%, #2d5016 100%);
    color: white;
    border: 1px solid #2d5016;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    font-weight: 600;
    font-size: 0.95em;
    box-shadow: 0 2px 8px rgba(31, 61, 16, 0.3);
}

.maintenance-header::before {
    content: "⚡";
    font-size: 1.2em;
    filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
}

.maintenance-header:hover {
    background: linear-gradient(135deg, #2d5016 0%, #3a6c1a 100%);
    border-color: #3a6c1a;
    box-shadow: 0 4px 12px rgba(31, 61, 16, 0.5);
    transform: translateY(-1px);
}

.maintenance-header:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(31, 61, 16, 0.3);
}

.maintenance-summary {
    display: none;
    padding: 8px 16px;
    background: rgba(45, 80, 22, 0.3);
    border: 1px solid rgba(45, 80, 22, 0.5);
    border-top: none;
    border-radius: 0 0 6px 6px;
    font-size: 0.85em;
    color: #aaa;
    margin-top: -6px;
}

.maintenance-summary.visible {
    display: block;
}

.maintenance-content {
    display: none;
    padding: 16px 0;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.calendar-container {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #3a3a3a;
}

.calendar-month {
    font-size: 1.1em;
    font-weight: 600;
    color: #7fb83e;
}

.calendar-nav {
    background: #3a3a3a;
    color: white;
    border: 1px solid #4a4a4a;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1em;
}

.calendar-nav:hover {
    background: #4a7c1f;
    border-color: #4a7c1f;
}

.calendar-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 8px;
    text-align: center;
    font-weight: 600;
    color: #888;
    font-size: 0.85em;
}

.calendar-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9em;
}

.calendar-day:hover:not(.disabled):not(.empty) {
    background: #3a3a3a;
    border-color: #4a7c1f;
    transform: scale(1.05);
}

.calendar-day.empty {
    background: transparent;
    border: none;
    cursor: default;
}

.calendar-day.disabled {
    background: #222;
    color: #555;
    cursor: not-allowed;
    opacity: 0.5;
}

.calendar-day.today {
    border-color: #7fb83e;
    border-width: 2px;
    font-weight: bold;
}

.calendar-day.selected {
    background: linear-gradient(135deg, #4a7c1f 0%, #5a8c2a 100%);
    color: white;
    border-color: #5a8c2a;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(74, 124, 31, 0.5);
}

.calendar-day.selected:hover {
    background: linear-gradient(135deg, #5a8c2a 0%, #6a9c3a 100%);
}

.calendar-programmed {
    padding: 12px;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.6;
}

.calendar-programmed div {
    color: #ccc;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    header h1 {
        font-size: 1.4em;
    }

    .locales-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .admin-links {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-tabs {
        flex-direction: column;
    }

    .tab-btn {
        width: 100%;
    }
    
    /* Responsive para calendario */
    .calendar-day {
        font-size: 12px;
    }
    
    .calendar-month {
        font-size: 14px;
    }
    
    .calendar-nav {
        padding: 4px 8px;
        font-size: 12px;
    }
}
