/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 30px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 15px;
    text-align: center;
}

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

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background: rgba(52, 152, 219, 0.1);
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.status-label {
    font-size: 0.9rem;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.status-value {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

.status-value.online { color: #27ae60; }
.status-value.offline { color: #e74c3c; }
.status-value.active { color: #f39c12; }
.status-value.alarm { color: #e74c3c; animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main Content */
main {
    display: grid;
    gap: 30px;
}

section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

section h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 20px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}

/* Temperature Grid */
.terrarium-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: repeat(5, 1fr);
    gap: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.terrarium-card {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #dee2e6;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.terrarium-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: #28a745;
    transition: background 0.3s ease;
}

.terrarium-card.high::before { background: #ffc107; }
.terrarium-card.emergency::before { background: #fd7e14; }
.terrarium-card.critical::before { background: #dc3545; animation: pulse 1s infinite; }
.terrarium-card.error::before { background: #6c757d; }

.terrarium-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.terrarium-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.terrarium-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #495057;
}

.terrarium-status {
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-normal { background: #d4edda; color: #155724; }
.status-high { background: #fff3cd; color: #856404; }
.status-emergency { background: #f8d7da; color: #721c24; }
.status-critical { background: #f5c6cb; color: #721c24; }
.status-error { background: #d1ecf1; color: #0c5460; }

.temperature-display {
    text-align: center;
    margin: 20px 0;
}

.current-temp {
    font-size: 3rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 5px;
}

.temp-unit {
    font-size: 1.5rem;
    color: #6c757d;
}

.temp-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.temp-detail {
    text-align: center;
    padding: 8px;
    background: rgba(108, 117, 125, 0.1);
    border-radius: 6px;
}

.temp-detail-label {
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 2px;
}

.temp-detail-value {
    font-size: 1rem;
    font-weight: bold;
    color: #495057;
}

/* Controls Panel */
.control-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.control-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.control-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.control-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mist-btn { background: #17a2b8; color: white; }
.mist-btn:hover:not(:disabled) { background: #138496; }

.stop-btn { background: #dc3545; color: white; }
.stop-btn:hover:not(:disabled) { background: #c82333; }

.alarm-btn { background: #ffc107; color: #212529; }
.alarm-btn:hover:not(:disabled) { background: #e0a800; }

.refresh-btn { background: #28a745; color: white; }
.refresh-btn:hover:not(:disabled) { background: #218838; }

.save-btn { background: #007bff; color: white; }
.save-btn:hover:not(:disabled) { background: #0056b3; }

.reset-btn { background: #6c757d; color: white; }
.reset-btn:hover:not(:disabled) { background: #545b62; }

.misting-duration {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: rgba(0, 123, 255, 0.1);
    border-radius: 8px;
}

.misting-duration input {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    width: 100px;
}

/* Settings Panel */
.settings-tabs {
    display: flex;
    margin-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
}

.tab-btn {
    padding: 12px 20px;
    border: none;
    background: none;
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn.active {
    border-bottom-color: #007bff;
    color: #007bff;
    font-weight: bold;
}

.tab-btn:hover {
    background: rgba(0, 123, 255, 0.1);
}

.tab-content {
    display: none;
}

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

.setting-group {
    margin-bottom: 20px;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.setting-group input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.setting-group input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.setting-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
}

.settings-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #dee2e6;
}

/* Info tooltips */
.info-icon {
    cursor: help;
    color: #007bff;
    font-size: 0.9rem;
    margin-left: 5px;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.info-icon:hover {
    opacity: 1;
}

/* Charts Section */
.chart-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.chart-controls select {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
}

.chart-container {
    position: relative;
    height: 400px;
    background: white;
    border-radius: 8px;
    padding: 20px;
}

/* Log Section */
.log-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.log-controls select,
.log-controls input {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 1rem;
}

.log-container {
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid #dee2e6;
    border-radius: 8px;
}

.log-entry {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 15px;
    align-items: center;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-entry:hover {
    background: rgba(0, 123, 255, 0.05);
}

.log-time {
    font-size: 0.9rem;
    color: #6c757d;
    font-family: monospace;
}

.log-message {
    font-size: 1rem;
    color: #495057;
}

.log-badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-mist { background: #cce5ff; color: #0056b3; }
.badge-alarm { background: #ffe6cc; color: #cc5500; }
.badge-emergency { background: #ffcccc; color: #cc0000; }

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast.success { background: #28a745; }
.toast.error { background: #dc3545; }
.toast.warning { background: #ffc107; color: #212529; }
.toast.info { background: #17a2b8; }

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .status-bar {
        grid-template-columns: 1fr 1fr;
    }
    
    .terrarium-grid {
        grid-template-columns: 1fr;
        grid-template-rows: none;
    }
    
    .control-buttons {
        grid-template-columns: 1fr 1fr;
    }
    
    .settings-tabs {
        flex-wrap: wrap;
    }
    
    .chart-controls,
    .log-controls {
        flex-direction: column;
    }
    
    .settings-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .status-bar {
        grid-template-columns: 1fr;
    }
    
    .control-buttons {
        grid-template-columns: 1fr;
    }
    
    .current-temp {
        font-size: 2.5rem;
    }
}

/* Sun Compass */
.sun-compass {
    margin-top: 8px;
    display: flex;
    justify-content: center;
}

.compass-face {
    position: relative;
    width: 60px;
    height: 60px;
    border: 2px solid #3498db;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
}

.compass-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    font-size: 18px;
    transform-origin: center;
    transform: translate(-50%, -50%) rotate(0deg);
    transition: transform 0.5s ease;
    z-index: 2;
    line-height: 1;
}

.compass-labels {
    position: absolute;
    width: 100%;
    height: 100%;
    font-size: 10px;
    font-weight: bold;
    color: #2c3e50;
}

.compass-labels span {
    position: absolute;
}

.compass-n {
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-s {
    top: 2px;
    left: 50%;
    transform: translateX(-50%);
}

.compass-e {
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.compass-w {
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
}

.sun-compass.nighttime .compass-face {
    background: rgba(0, 0, 0, 0.1);
    border-color: #7f8c8d;
}

.sun-compass.nighttime .compass-arrow {
    opacity: 0.3;
}

.sun-compass.nighttime .compass-labels {
    color: #7f8c8d;
} 