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

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

header {
    background-color: #2c3e50;
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

header h1 {
    text-align: center;
    margin-bottom: 1rem;
}

.header-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
}

.stat-value.online { color: #27ae60; }
.stat-value.offline { color: #e74c3c; }
.stat-value.alert { color: #f39c12; }

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #ddd;
    flex-wrap: wrap;
}

.tab-button {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    cursor: pointer;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: #2c3e50;
}

.tab-button.active {
    color: #2c3e50;
    border-bottom-color: #3498db;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
}

.card {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h3 {
    margin-bottom: 1rem;
    color: #2c3e50;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-danger {
    background-color: #e74c3c;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-warning {
    background-color: #f39c12;
    color: white;
}

.btn-warning:hover {
    background-color: #d68910;
}

.btn-info {
    background-color: #3498db;
    color: white;
}

.btn-info:hover {
    background-color: #2980b9;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.actions-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.search-input, .filter-select {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

.search-input {
    flex: 1;
    min-width: 200px;
}

.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.device-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.device-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.device-name {
    font-weight: bold;
    color: #2c3e50;
}

.device-status {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-online {
    background-color: #d4edda;
    color: #155724;
}

.status-offline {
    background-color: #f8d7da;
    color: #721c24;
}

.device-info {
    font-size: 0.85rem;
    color: #666;
}

.device-info p {
    margin: 0.25rem 0;
}

.loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
}

#deviceStatsChart {
    max-height: 400px;
    margin: 20px 0;
}

.modal-content.large {
    max-width: 900px;
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.close:hover {
    color: #333;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

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

.alert-item {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border-left: 4px solid #e74c3c;
}

.alert-item.acknowledged {
    border-left-color: #95a5a6;
    opacity: 0.7;
}

.alert-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.alert-info {
    font-size: 0.85rem;
    color: #666;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.stat-box {
    text-align: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.stat-box .value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #2c3e50;
}

.stat-box .label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.firmware-item {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.firmware-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.firmware-version {
    font-weight: bold;
    color: #2c3e50;
}

.firmware-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

.badge-stable {
    background-color: #d4edda;
    color: #155724;
}

.badge-auto-update {
    background-color: #cce5ff;
    color: #004085;
}

.map-container {
    height: 600px;
    background: #e0e0e0;
    border-radius: 8px;
    position: relative;
}

.chart-container {
    position: relative;
    height: 300px;
}

.targets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.target-card {
    background: white;
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.target-address {
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.target-type {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #e3f2fd;
    color: #1565c0;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        gap: 0.5rem;
    }
    
    .tab-button {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

.device-actions {
    margin-top: 20px;
    padding: 20px;
    border-top: 1px solid #ddd;
}

.command-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.command-buttons .btn {
    flex: 0 0 auto;
}

.advanced-actions {
    margin-top: 30px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 5px;
}

.advanced-actions h4 {
    margin-bottom: 20px;
}

.advanced-actions .form-group {
    margin-bottom: 15px;
}

.advanced-actions label {
    display: block;
    margin-bottom: 5px;
}

/* ==========================================
   CLIMA MODULE STYLES
   ========================================== */

/* Clima device list */
.clima-devices-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.clima-device-item {
    background: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clima-device-item:hover {
    border-color: #3498db;
    background: #f0f7ff;
}

.clima-device-item.selected {
    border-color: #3498db;
    background: #e3f2fd;
}

.clima-device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.clima-device-header .device-name {
    font-weight: bold;
    color: #2c3e50;
}

.clima-device-values {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.clima-device-values .temp-value {
    color: #e74c3c;
    font-weight: 600;
}

.clima-device-values .hum-value {
    color: #3498db;
    font-weight: 600;
}

.clima-device-values .no-data {
    color: #999;
    font-style: italic;
}

.clima-device-time {
    font-size: 0.8rem;
    color: #666;
}

/* Status badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.online {
    background: #d4edda;
    color: #155724;
}

.status-badge.offline {
    background: #f8d7da;
    color: #721c24;
}

/* Clima cards */
.clima-card {
    text-align: center;
}

.clima-card.temperatura {
    border-top: 4px solid #e74c3c;
}

.clima-card.humedad {
    border-top: 4px solid #3498db;
}

.clima-value {
    display: flex;
    justify-content: center;
    align-items: baseline;
    margin: 1.5rem 0;
}

.clima-value .big-value {
    font-size: 4rem;
    font-weight: bold;
    line-height: 1;
}

.clima-card.temperatura .big-value {
    color: #e74c3c;
}

.clima-card.humedad .big-value {
    color: #3498db;
}

.clima-value .unit {
    font-size: 1.5rem;
    color: #666;
    margin-left: 0.25rem;
}

.clima-stats {
    display: flex;
    justify-content: space-around;
    padding-top: 1rem;
    border-top: 1px solid #eee;
    color: #666;
    font-size: 0.9rem;
}

.clima-stats span {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.clima-last-update {
    font-size: 1.5rem;
    color: #2c3e50;
    text-align: center;
    padding: 2rem 0;
}

/* No data message */
.no-data-message {
    text-align: center;
    padding: 3rem;
    color: #666;
}

.no-data-message h3 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.no-data-message p {
    margin-bottom: 0.5rem;
}

.no-data-message code {
    display: inline-block;
    background: #f1f1f1;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: monospace;
    margin: 0.5rem 0;
    color: #c7254e;
}

/* Responsive */
@media (max-width: 768px) {
    .clima-value .big-value {
        font-size: 3rem;
    }

    .clima-stats {
        flex-direction: column;
        gap: 0.5rem;
    }

    .clima-device-values {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Filter buttons */
.filter-buttons {
    display: flex;
    gap: 0.5rem;
    margin-right: 1rem;
}

.btn-filter {
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.btn-filter:hover {
    border-color: #3498db;
    background: #f0f8ff;
}

.btn-filter.active {
    border-color: #3498db;
    background: #3498db;
    color: white;
}

/* Sensor type badges */
.device-badges {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.sensor-badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.sensor-badge.indoor {
    background: #e8f4fd;
    color: #2980b9;
    border: 1px solid #3498db;
}

.sensor-badge.outdoor {
    background: #e8fdf4;
    color: #27ae60;
    border: 1px solid #27ae60;
}

.sensor-badge.unknown {
    background: #f5f5f5;
    color: #7f8c8d;
    border: 1px solid #bdc3c7;
}

/* Profile selector in device modal */
.profile-section {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.profile-section h3 {
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .filter-buttons {
        flex-wrap: wrap;
        margin-right: 0;
        margin-bottom: 0.5rem;
    }

    .btn-filter {
        flex: 1;
        text-align: center;
    }
}

/* RRD Graph Styles */
.rrd-graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}

.rrd-graph-header h3 {
    margin: 0;
}

.rrd-period-selector {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
}

.period-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border: 1px solid #3a3a5a;
    background: #16213e;
    color: #a0a0a0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.period-btn:hover {
    background: #1a1a2e;
    color: #fff;
    border-color: #5a5a7a;
}

.period-btn.active {
    background: #3498db;
    color: #fff;
    border-color: #3498db;
}

.rrd-graphs-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rrd-graph-item {
    background: #1a1a2e;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 280px;
}

.rrd-graph-img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.rrd-graph-img.loading {
    opacity: 0.5;
}

.rrd-graph-img[src=""] {
    display: none;
}

.rrd-graph-actions {
    margin-top: 1rem;
    text-align: center;
}

@media (max-width: 768px) {
    .rrd-graph-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .rrd-period-selector {
        width: 100%;
    }

    .period-btn {
        flex: 1;
        text-align: center;
        padding: 0.5rem;
        font-size: 0.75rem;
    }

    .rrd-graph-item {
        min-height: 200px;
    }
}

/* SNMP Configuration Styles */
.snmp-config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

@media (max-width: 900px) {
    .snmp-config-grid {
        grid-template-columns: 1fr;
    }
}

.snmp-config-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: visible;
}

.snmp-config-form .form-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.snmp-config-form label {
    font-weight: 500;
    color: #e0e0e0;
}

.snmp-config-form .form-control {
    padding: 0.6rem 0.8rem;
    border: 1px solid #3a3a5a;
    border-radius: 4px;
    background: #1a1a2e;
    color: #fff;
    font-size: 0.95rem;
}

.snmp-config-form .form-control:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

.snmp-config-form .form-control:disabled,
.snmp-config-form .form-control.disabled {
    background: #0d0d1a;
    color: #666;
    cursor: not-allowed;
}

.snmp-config-form small {
    font-size: 0.8rem;
    color: #888;
}

.snmp-config-form .form-actions {
    margin-top: 1rem;
    padding: 1rem 0;
}

.snmp-config-form .form-actions .btn {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
}

/* Toggle Switch */
.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    user-select: none;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 50px;
    height: 26px;
    background: #3a3a5a;
    border-radius: 13px;
    transition: all 0.3s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider {
    background: #27ae60;
}

.toggle-label input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* SNMP Config Info */
.snmp-config-info {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.snmp-status {
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.snmp-oids h4,
.snmp-test h4 {
    margin-bottom: 0.5rem;
    color: #e0e0e0;
}

.oid-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.oid-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid #2a2a4a;
}

.oid-table td:first-child {
    font-weight: 500;
    color: #a0a0a0;
    width: 100px;
}

.oid-table code {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: #3498db;
    word-break: break-all;
}

.snmp-test code {
    display: block;
    background: #0d0d1a;
    padding: 0.8rem;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    color: #27ae60;
    overflow-x: auto;
    white-space: nowrap;
}

/* Collapsible Card Header */
.card-header-collapsible {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem 0;
    border-bottom: 1px solid #2a2a4a;
    margin-bottom: 0;
    transition: margin-bottom 0.3s ease;
}

.card-header-collapsible:hover {
    opacity: 0.9;
}

.card-header-collapsible h3 {
    margin: 0;
}

.collapse-icon {
    font-size: 1rem;
    transition: transform 0.3s ease;
    color: #a0a0a0;
}

.card-header-collapsible.expanded .collapse-icon {
    transform: rotate(180deg);
}

/* Collapsible Content */
.snmp-config-content {
    overflow: visible;
    max-height: none;
    opacity: 1;
    padding-top: 1rem;
    transition: opacity 0.3s ease, padding 0.3s ease;
}

.snmp-config-content.collapsed {
    display: none;
}
