/**
 * Estilos comunes para la aplicación de Estación Meteorológica
 * Incluye estilos para login, registro, dashboard y componentes compartidos
 */

/* ==================== RESET Y BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
}

/* ==================== HEADER ==================== */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    font-size: 1.8em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info span {
    color: white;
    font-weight: 500;
}

.user-info .btn {
    background: white;
    color: #667eea;
    padding: 8px 20px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.user-info .btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* Menú de usuario hamburguesa */
.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Language Flags */
.language-selector {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lang-flag {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    min-height: 40px;
}

.lang-flag:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.lang-flag.active {
    background: white;
    border-color: white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.lang-flag.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: all 0.3s ease;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle:hover span {
    background: #e0e0e0;
}

.user-dropdown {
    position: absolute;
    top: 45px;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.user-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-welcome {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
    font-weight: 600;
    font-size: 0.95em;
}

.dropdown-item {
    display: block;
    padding: 12px 15px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background: #f5f5f5;
    color: #764ba2;
}

/* ==================== CONTENEDORES ==================== */
.container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 20px;
}

@media (max-width: 768px) {
    .container {
        padding: 0 8px;
        margin: 15px auto;
    }
    
    .header h1 {
        font-size: 1.3em;
    }
    
    .lang-flag {
        font-size: 1.3em;
        min-width: 38px;
        min-height: 35px;
        padding: 4px 8px;
    }
    
    .language-selector {
        gap: 6px;
    }
    
    .lang-flag-auth {
        font-size: 1.3em;
        min-width: 38px;
        min-height: 35px;
        padding: 4px 8px;
    }
    
    .language-selector-auth {
        gap: 6px;
        top: 15px;
        right: 15px;
    }
}

.section {
    background: white;
    border-radius: 10px;
    padding: 0;
    margin-bottom: 30px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow: hidden;
    box-sizing: border-box;
}

.section-title {
    font-size: 1.8em;
    color: #333;
    margin: 0;
    padding: 20px 30px;
    border-bottom: 3px solid #667eea;
    cursor: pointer;
    user-select: none;
    transition: background 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-title:hover {
    background: #f8f9fa;
}

.section-title::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.3s ease;
    color: #667eea;
}

.section-title.collapsed::after {
    transform: rotate(-90deg);
}

.section-content {
    padding: 20px;
    display: block;
    box-sizing: border-box;
    overflow: hidden;
}

.section-content.collapsed {
    display: none;
}

/* ==================== SUBSECCIONES ==================== */
.subsection {
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.subsection:last-child {
    margin-bottom: 0;
}

.subsection-title {
    font-size: 1.3em;
    color: #333;
    margin: 0;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    user-select: none;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subsection-title:hover {
    opacity: 0.9;
}

.subsection-title::after {
    content: '▼';
    font-size: 0.7em;
    transition: transform 0.3s ease;
}

.subsection-title.collapsed::after {
    transform: rotate(-90deg);
}

.subsection-content {
    padding: 0;
    display: block;
    background: white;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.subsection-content.collapsed {
    display: none;
}

/* Map specific styles */
#dashboard-map {
    margin: 0;
}

#map-info {
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

@media (max-width: 768px) {
    .subsection-title {
        font-size: 1.1em;
        padding: 12px 15px;
    }
    
    #dashboard-map {
        height: 300px !important;
    }
}


/* ==================== TOGGLE SWITCH ==================== */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:focus + .slider {
    box-shadow: 0 0 1px #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* ==================== BOTONES ==================== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
    font-size: 0.9em;
    padding: 8px 16px;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
    color: #667eea;
}

.btn-icon:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.btn-icon.active {
    background: rgba(102, 126, 234, 0.2);
}

/* ==================== FORMULARIOS ==================== */
.form-group {
    margin-bottom: 20px;
    box-sizing: border-box;
}

label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-inline {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.form-inline .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* ==================== DISPOSITIVOS ==================== */
.devices-grid,
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

@media (max-width: 768px) {
    .devices-grid,
    .device-grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 0 10px;
    }
}

.device-card {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
    width: 100%;
    max-width: 100%;
}

@media (max-width: 768px) {
    .device-card {
        padding: 12px;
        margin: 0 auto;
    }
}

.device-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.device-header h3,
.device-title {
    color: #333;
    font-size: 1.2em;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.status-indicator.online {
    background: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
}

.status-indicator.offline {
    background: #dc3545;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
}

.device-summary {
    display: flex;
    gap: 15px;
    margin: 15px 0 15px 0;
    padding: 0 5px;
}

.device-weather-section {
    flex: 0 0 auto;
    width: calc(50% - 7.5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.device-weather-icon-large {
    font-size: 4em;
    line-height: 1;
    margin-bottom: 8px;
}

.weather-text {
    font-weight: 500;
    font-size: 0.95em;
    color: #555;
    text-align: center;
}

.device-forecast-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 10px;
}

.device-trend {
    font-size: 0.9em;
    color: #555;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #4CAF50;
}

.device-prediction {
    font-size: 0.85em;
    color: #2196F3;
    padding: 10px;
    background: #E3F2FD;
    border-radius: 6px;
    border-left: 3px solid #2196F3;
    font-style: italic;
}

.sensor-clickable {
    cursor: pointer;
    transition: all 0.2s ease;
}

.sensor-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    background: #f0f7ff;
    border-color: #2196F3;
}

.sensor-clickable:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.weather-text {
    font-weight: 500;
}

.device-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid rgba(0,0,0,0.1);
}

/* Quick Chart Modal - Optimizado para móvil */
.quick-chart-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.quick-chart-modal.show {
    opacity: 1;
}

.quick-chart-content {
    background: white;
    border-radius: 12px;
    width: 95%;
    max-width: 900px;
    height: 85vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.quick-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.quick-chart-header h3 {
    margin: 0;
    font-size: 1.2em;
    font-weight: 600;
}

.quick-chart-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    cursor: pointer;
    padding: 0;
    width: 35px;
    height: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.quick-chart-close:hover {
    background: rgba(255,255,255,0.2);
}

.quick-chart-tabs {
    display: flex;
    overflow-x: auto;
    background: #f8f9fa;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 10px;
    -webkit-overflow-scrolling: touch;
}

.quick-chart-tab {
    flex: 0 0 auto;
    padding: 12px 16px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 0.9em;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-chart-tab:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.quick-chart-tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
    font-weight: 600;
}

.quick-chart-range-buttons {
    display: flex;
    gap: 8px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.quick-range-btn {
    flex: 0 0 auto;
    padding: 6px 14px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
    white-space: nowrap;
}

.quick-range-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.quick-range-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 2px 5px rgba(102, 126, 234, 0.3);
}

/* Custom date range picker */
.quick-custom-range {
    margin: 15px 20px 0 20px;
    padding: 15px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

.custom-range-inputs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 10px;
}

.custom-range-inputs input[type="datetime-local"] {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9em;
    background: white;
    color: #333;
}

.custom-range-inputs input[type="datetime-local"]:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-apply-range {
    padding: 8px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9em;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-apply-range:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.3);
}

.btn-apply-range:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.quick-chart-body {
    flex: 1;
    padding: 20px;
    overflow: hidden;
    position: relative;
}

.quick-chart-body canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Responsive para móvil */
@media (max-width: 768px) {
    .quick-chart-content {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .quick-chart-header {
        padding: 12px 15px;
    }
    
    .quick-chart-header h3 {
        font-size: 1.1em;
    }
    
    .quick-chart-tabs {
        padding: 0 5px;
    }
    
    .quick-chart-tab {
        padding: 10px 12px;
        font-size: 0.85em;
    }
    
    .quick-chart-body {
        padding: 15px 10px;
    }
    
    .quick-custom-range {
        margin: 15px 10px 0 10px;
        padding: 10px;
    }
    
    .custom-range-inputs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .custom-range-inputs input[type="datetime-local"] {
        min-width: unset;
        width: 100%;
    }
    
    .btn-apply-range {
        width: 100%;
    }
}

.btn-action {
    flex: 1 !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    /* padding: 5px 5px !important;*/
    border-radius: 6px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    font-size: 0.85em !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
    text-decoration: none !important;
    white-space: nowrap !important;
    min-height: 40px !important;
}

.btn-action:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
}

.btn-action:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1) !important;
}

.btn-action.active {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%) !important;
    box-shadow: 0 3px 10px rgba(118, 75, 162, 0.4) !important;
}

.btn-action span {
    font-size: 1.1em !important;
}

.btn-action.btn-icon-only {
    flex: 0 0 auto !important;
    min-width: 50px !important;
    padding: 10px !important;
}

.btn-action.btn-icon-only span {
    font-size: 1.3em !important;
}

.device-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
}

.status-online {
    background: #d4edda;
    color: #155724;
}

.status-offline {
    background: #f8d7da;
    color: #721c24;
}

.device-info {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 0.9em;
    color: #666;
}

.device-info div {
    margin-bottom: 5px;
}

.weather-icon {
    font-size: 1.5em;
    margin-right: 8px;
    vertical-align: middle;
}

.sensors-grid,
.sensor-data {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 15px 0 0 0;
    padding: 0 5px;
}

@media (max-width: 768px) {
    .sensor-data {
        gap: 10px;
    }
}

.sensor-item,
.sensor-value {
    background: white;
    padding: 12px;
    border-radius: 8px;
}

@media (max-width: 768px) {
    .sensor-item,
    .sensor-value {
        padding: 10px 8px;
    }
}

.sensor-item {
    border-left: 4px solid #667eea;
}

.sensor-label {
    font-size: 0.85em;
    color: #666;
    margin-bottom: 5px;
}

@media (max-width: 768px) {
    .sensor-label {
        font-size: 0.75em;
        margin-bottom: 3px;
    }
}

.sensor-number {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
}

@media (max-width: 768px) {
    .sensor-number {
        font-size: 1.3em;
        word-break: break-word;
    }
}

.sensor-unit {
    font-size: 1em;
    color: #666;
}

/* ==================== CONFIGURACIÓN ==================== */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.sync-status {
    padding: 10px;
    border-radius: 6px;
    margin-top: 10px;
    font-size: 0.9em;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.sync-status.show {
    display: block;
    opacity: 1;
}

.sync-status.pending {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.sync-status.synced {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.sync-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ==================== API KEYS ==================== */
.api-section-compact {
    background: #f8f9fa;
    padding: 15px 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 20px;
}

.api-section-compact:hover {
    background: #e9ecef;
}

.api-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.api-section-title {
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.api-section-toggle {
    font-size: 1.5em;
    color: #667eea;
    transition: transform 0.3s ease;
}

.api-section-toggle.expanded {
    transform: rotate(180deg);
}

.api-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.api-section-content.show {
    max-height: 2000px;
    margin-top: 20px;
}

.api-keys-list {
    display: grid;
    gap: 15px;
}

.api-key-item {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    margin-bottom: 15px;
}

.api-key-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.api-key-name {
    font-weight: 600;
    color: #333;
    font-size: 1.1em;
}

.api-key-value {
    font-family: monospace;
    background: white;
    padding: 10px;
    border-radius: 5px;
    word-break: break-all;
    margin: 10px 0;
    border: 1px solid #ddd;
}

.api-key-info {
    font-size: 0.9em;
    color: #666;
}

/* ==================== GRÁFICAS ==================== */
.chart-container {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 100%;
}

.chart-container.unified {
    height: calc(100vh - 220px);
    min-height: 300px;
}

.chart-container h5 {
    margin-bottom: 15px;
    color: #333;
}

.chart-canvas {
    height: 100% !important;
    max-height: none !important;
}

.time-range-selector {
    background: white;
    border-radius: 10px;
    padding: 12px 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.range-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.range-btn {
    padding: 8px 16px;
    border: 2px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 0.9em;
}

.range-btn:hover {
    background: #f0f0f0;
}

.range-btn.active {
    background: #667eea;
    color: white;
}

.custom-range {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
}

.custom-range-inputs {
    display: flex;
    gap: 15px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.input-group input[type="datetime-local"] {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

/* ==================== MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: #fefefe;
    margin: 0 auto;
    padding: 0;
    border-radius: 10px;
    width: 90%;
    height: 90vh;
    max-width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s ease;
    position: relative;
    top: 5vh;
}

.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 25px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5em;
}

.modal-close {
    color: white;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    transition: transform 0.2s ease;
}

.modal-close:hover {
    transform: scale(1.2);
}

.modal-body {
    padding: 20px;
    height: calc(90vh - 80px);
    overflow-y: auto;
}

/* ==================== PÁGINA DE LOGIN/REGISTRO ==================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-box {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 450px;
    width: 100%;
    position: relative;
}

.auth-box h1 {
    color: #333;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2em;
}

.auth-box p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

/* Language Flags for Auth Pages */
.language-selector-auth {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
}

.lang-flag-auth {
    background: rgba(102, 126, 234, 0.1);
    border: 2px solid rgba(102, 126, 234, 0.3);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 1.5em;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 45px;
    min-height: 40px;
}

.lang-flag-auth:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.lang-flag-auth.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.4);
}

.lang-flag-auth.active:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.5);
}

.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 0.95em;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.auth-links {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-links a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-links a:hover {
    text-decoration: underline;
}

/* ==================== MENSAJES ==================== */
.message {
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease;
}

.message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ==================== ANIMACIONES ==================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==================== UTILIDADES ==================== */
.text-center {
    text-align: center;
}

.mb-20 {
    margin-bottom: 20px;
}

.mt-20 {
    margin-top: 20px;
}

/* ==================== PROFILE PAGE ==================== */
.profile-form {
    max-width: 100%;
    box-sizing: border-box;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.form-group {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.form-group label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95em;
}

.form-group input,
.form-group select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group input:disabled,
.form-group input[readonly] {
    background: #f5f5f5;
    cursor: not-allowed;
    color: #666;
}

.readonly-label {
    font-size: 0.85em;
    color: #999;
    font-weight: normal;
}

.form-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    box-sizing: border-box;
}

.info-item {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.info-item strong {
    display: block;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.info-item span {
    color: #333;
    font-size: 1em;
}

/* ==================== ADMIN PANEL ==================== */
.admin-form {
    max-width: 100%;
}

.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="email"],
.admin-form input[type="password"],
.admin-form select,
.admin-form textarea {
    max-width: 100%;
    box-sizing: border-box;
}

.table-responsive {
    overflow-x: auto;
    margin-top: 20px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.admin-table thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.admin-table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
}

.admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.admin-table tbody tr:hover {
    background: #f8f9fa;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.inactive-row {
    opacity: 0.6;
    background: #f5f5f5;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.badge-admin {
    background: #ff6384;
    color: white;
}

.badge-viewer {
    background: #36a2eb;
    color: white;
}

.badge-success {
    background: #4caf50;
    color: white;
}

.badge-error {
    background: #f44336;
    color: white;
}

.badge-info {
    background: #667eea;
    color: white;
}

.badge-shared {
    background: #ff9800;
    color: white;
    font-size: 0.75em;
    margin-left: 8px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px 8px;
    transition: transform 0.2s ease;
}

.btn-icon:hover {
    transform: scale(1.2);
}

.btn-icon.btn-danger:hover {
    filter: brightness(1.2);
}

.modal-small .modal-content {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .devices-grid {
        grid-template-columns: 1fr;
    }
    
    .sensors-grid {
        grid-template-columns: 1fr;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .form-inline {
        flex-direction: column;
    }
    
    .device-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .range-buttons {
        flex-direction: column;
    }
    
    .range-btn {
        width: 100%;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-table {
        font-size: 0.85em;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 8px 10px;
    }
}

/* ==================== TIMEZONE SELECT STYLING ==================== */
select optgroup {
    font-weight: bold;
    font-style: normal;
    color: #667eea;
    background-color: #f5f5f5;
}

select option {
    font-weight: normal;
    padding: 5px;
    color: #333;
}

/* ==================== CLASES PARA TENDENCIAS Y PREDICCIONES ==================== */
/* Colores para valores numéricos positivos/negativos */
.positive {
    color: #22c55e;
    font-weight: 500;
}

.negative {
    color: #ef4444;
    font-weight: 500;
}

.stable {
    color: #3b82f6;
    font-weight: 500;
}

.neutral {
    color: #64748b;
    font-weight: 400;
}

/* Variantes con fondo para destacar */
.positive-bg {
    background-color: #dcfce7;
    color: #166534;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.negative-bg {
    background-color: #fee2e2;
    color: #991b1b;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.stable-bg {
    background-color: #dbeafe;
    color: #1e40af;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.neutral-bg {
    background-color: #f1f5f9;
    color: #475569;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 400;
}
