/* Reset e Variáveis */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Estado vazio para tabelas e gráficos */
.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--dark-gray);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--gray-color);
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.empty-state small {
    color: var(--gray-color);
}

.no-data {
    text-align: center;
    padding: 2rem !important;
    background-color: var(--light-gray);
}

:root {
    --primary-color: #2ecc71;
    --secondary-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f1c40f;
    --info-color: #3498db;
    --gray-color: #95a5a6;
    --dark-gray: #34495e;
    --light-gray: #ecf0f1;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #3498db;
    --dark-bg: #1a1a2e;
    --card-bg: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo i {
    font-size: 2.5rem;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.header-info {
    display: flex;
    gap: 30px;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}

.status-indicator i {
    font-size: 0.7rem;
    animation: pulse 2s infinite;
}

.status-indicator.connected i {
    color: var(--primary-color);
}

.status-indicator.disconnected i {
    color: var(--danger-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.last-update {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

/* Seletor de Dispositivo */
.device-selector {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px 30px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
}

.device-selector label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.device-selector select {
    flex: 1;
    min-width: 250px;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
}

.device-selector select:hover,
.device-selector select:focus {
    border-color: var(--primary-color);
    outline: none;
}

.btn-refresh {
    padding: 10px 20px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-refresh:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

/* Grid de Sensores */
.sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.sensor-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border-left: 4px solid var(--primary-color);
}

.sensor-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 12px rgba(0, 0, 0, 0.4);
}

.sensor-card.water-temp { border-left-color: #3498db; }
.sensor-card.tds { border-left-color: #2ecc71; }
.sensor-card.ph { border-left-color: #f39c12; }
.sensor-card.air-temp { border-left-color: #e74c3c; }
.sensor-card.humidity { border-left-color: #9b59b6; }
.sensor-card.device-info { border-left-color: #34495e; }

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.card-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    margin-bottom: 20px;
}

.main-value {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 15px;
}

.main-value .value {
    font-size: 3rem;
    font-weight: 700;
    color: var(--primary-color);
}

.main-value .unit {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

.secondary-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-item .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
    background: rgba(46, 204, 113, 0.2);
    color: var(--primary-color);
}

.status-badge.warning {
    background: rgba(243, 156, 18, 0.2);
    color: var(--warning-color);
}

.status-badge.danger {
    background: rgba(231, 76, 60, 0.2);
    color: var(--danger-color);
}

/* Status de Cultivo - Baseado em Parâmetros */
.status-badge.status-ideal {
    background: #2ecc71;
    color: #ffffff;
}

.status-badge.status-atenção {
    background: #f39c12;
    color: #ffffff;
}

.status-badge.status-crítico {
    background: #e74c3c;
    color: #ffffff;
    animation: pulse-alert 2s infinite;
}

.status-badge.status-sem.dados {
    background: #95a5a6;
    color: #ffffff;
}

@keyframes pulse-alert {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Device Info Card */
.device-details {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.detail-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
}

/* Charts */
.card-chart {
    height: 150px;
    margin-top: 15px;
}

.card-chart canvas {
    max-height: 150px;
}

/* History Section */
.history-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.4rem;
}

.section-header h2 i {
    color: var(--primary-color);
}

.history-controls select {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

.history-controls select:hover {
    border-color: var(--primary-color);
}

.history-chart-container {
    height: 400px;
    position: relative;
}

.history-chart-container canvas {
    max-height: 400px;
}

/* Table Section */
.data-table-section {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

.btn-export {
    padding: 10px 20px;
    background: var(--info-color);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-export:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.table-wrapper {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

tbody td {
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.no-data {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px !important;
}

/* Footer */
.footer {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    margin-top: 40px;
}

.footer p {
    margin: 5px 0;
}

.footer i {
    color: var(--danger-color);
}

/* Responsive */
@media (max-width: 768px) {
    .sensors-grid {
        grid-template-columns: 1fr;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .header-info {
        flex-direction: column;
        gap: 15px;
    }
    
    .device-selector {
        flex-direction: column;
    }
    
    .device-selector select {
        width: 100%;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .main-value .value {
        font-size: 2.5rem;
    }
}

/* Loading Animation */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.loading {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}
