/* ===== RESET & BASE STYLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f8fafc;
    color: #333;
    line-height: 1.6;
}

/* ===== SIDEBAR STYLES ===== */
.sidebar {
    width: 250px;
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar.collapsed {
    width: 70px;
}

.sidebar-toggle {
    padding: 15px;
    text-align: center;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.1);
}

.sidebar-content h2 {
    padding: 20px 15px;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar ul li a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.sidebar ul li a:hover,
.sidebar ul li a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

.sidebar ul li a i {
    width: 18px;
    margin-right: 12px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    padding: 15px;
    border-top: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.1);
}

.user-info, .system-status {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.user-info i, .system-status i {
    margin-right: 8px;
    font-size: 0.9rem;
}

.status-online {
    color: #10b981;
}

.sidebar-text {
    transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed ul li a {
    justify-content: center;
    padding: 12px 10px;
}

.sidebar.collapsed ul li a i {
    margin-right: 0;
}

.sidebar.collapsed .sidebar-footer {
    text-align: center;
}

.sidebar.collapsed .sidebar-footer .sidebar-text {
    display: none;
}

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: 250px;
    transition: all 0.3s ease;
    min-height: 100vh;
    background: #f8fafc;
}

.main-content.expanded {
    margin-left: 70px;
}

.navbar {
    background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%);
    color: white;
    padding: 15px 30px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.subnav {
    background: white;
    padding: 12px 30px;
    border-bottom: 1px solid #e5e7eb;
    color: #6b7280;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== SECTION VISIBILITY ===== */
.content-section {
    display: none;
    padding: 25px 30px;
}

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

/* ===== CARDS & GRIDS ===== */
.sensor-section, .status-section, .device-section {
    margin-bottom: 30px;
}

.sensor-section h3, .status-section h3, .device-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sensor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

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

.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
}

.card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    transition: all 0.3s ease;
}

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

/* ===== SENSOR CARDS ===== */
.sensor-card {
    text-align: center;
    position: relative;
}

.sensor-card .card-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 1.8rem;
}

.sensor-card .card-icon i {
    font-size: 1.8rem;
}

.sensor-card .title {
    font-size: 0.9rem;
    color: #6b7280;
    margin-bottom: 8px;
    font-weight: 500;
}

.sensor-card .value {
    font-size: 2.2rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 5px;
}

/* Color themes for sensor cards */
.sensor-card:nth-child(1) .card-icon {
    background: #fee2e2;
    color: #dc2626;
}

.sensor-card:nth-child(2) .card-icon {
    background: #dbeafe;
    color: #2563eb;
}

.sensor-card:nth-child(3) .card-icon {
    background: #dcfce7;
    color: #16a34a;
}

.sensor-card:nth-child(4) .card-icon {
    background: #fef3c7;
    color: #d97706;
}

.sensor-card:nth-child(5) .card-icon {
    background: #fef3c7;
    color: #d97706;
}

/* ===== STATUS CARDS ===== */
.status-card .card-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.status-card .title {
    font-size: 1rem;
    color: #374151;
    margin-bottom: 10px;
    font-weight: 600;
}

.status-card .value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #1f2937;
    margin-bottom: 10px;
}

.status-on {
    color: #16a34a;
    font-weight: 600;
}

.status-off {
    color: #dc2626;
    font-weight: 600;
}

.work-hours-info {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.4;
}

.daily-usage, .shutdown-info {
    font-size: 0.85rem;
    color: #6b7280;
}

.usage-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

/* Color themes for status cards */
.status-card:nth-child(1) .card-icon {
    background: #dbeafe;
    color: #2563eb;
}

.status-card:nth-child(2) .card-icon {
    background: #dcfce7;
    color: #16a34a;
}

.status-card:nth-child(3) .card-icon {
    background: #f3e8ff;
    color: #9333ea;
}

.status-card:nth-child(4) .card-icon {
    background: #fef3c7;
    color: #d97706;
}

/* ===== DEVICE CARDS ===== */
.device-card .card-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    font-size: 1.5rem;
}

.device-card .title {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.device-card .device-info {
    font-size: 0.85rem;
    color: #6b7280;
    margin-bottom: 15px;
}

.device-card button {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}

.ac-card .card-icon {
    background: #dbeafe;
    color: #2563eb;
}

.ac-card button {
    background: #2563eb;
    color: white;
}

.ac-card button:hover {
    background: #1d4ed8;
}

.lamp-card .card-icon {
    background: #fef3c7;
    color: #d97706;
}

.lamp-card button {
    background: #d97706;
    color: white;
}

.lamp-card button:hover {
    background: #b45309;
}

.device-card:not(.ac-card):not(.lamp-card) .card-icon {
    background: #fee2e2;
    color: #dc2626;
}

.device-card:not(.ac-card):not(.lamp-card) button {
    background: #dc2626;
    color: white;
}

.device-card:not(.ac-card):not(.lamp-card) button:hover {
    background: #b91c1c;
}

/* ===== AC & LAMP UNIT CONTROLS ===== */
.ac-units-status, .lamp-circuits-status {
    margin: 15px 0;
}

.ac-unit, .lamp-circuit {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding: 8px 12px;
    background: #f9fafb;
    border-radius: 6px;
    font-size: 0.9rem;
}

.mini-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    color: white;
    margin-right: 8px;
}

.mini-status.status-on {
    background: #16a34a;
}

.mini-status.status-off {
    background: #dc2626;
}

.mini-btn {
    padding: 6px 10px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.mini-btn:hover {
    background: #1d4ed8;
}

/* ===== DEVICE CONTROLS ===== */
.device-controls {
    margin-top: 15px;
    text-align: center;
}

.device-controls .title {
    font-weight: 600;
    margin-bottom: 8px;
}

.device-controls .value {
    font-size: 1.5rem;
    font-weight: bold;
    margin: 10px 0;
}

.temp-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 10px 0;
}

.temp-btn {
    padding: 8px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: white;
}

.temp-btn:first-child {
    background: #dc2626;
}

.temp-btn:first-child:hover {
    background: #b91c1c;
}

.temp-btn:last-child {
    background: #2563eb;
}

.temp-btn:last-child:hover {
    background: #1d4ed8;
}

.gradual-controls {
    margin-top: 10px;
}

.btn-small {
    padding: 6px 10px;
    background: #16a34a;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.btn-small:hover {
    background: #15803d;
}

/* ===== HISTORY SECTION ===== */
.history-tabs {
    display: flex;
    gap: 5px;
    margin: 20px 0;
    border-bottom: 2px solid #e5e7eb;
}

.tab-button {
    padding: 10px 20px;
    border: none;
    background: #e5e7eb;
    color: #374151;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.tab-button.active {
    background: #6366f1;
    color: white;
}

.tab-button:hover:not(.active) {
    background: #d1d5db;
}

.history-table-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-top: 20px;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.history-table th,
.history-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.history-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.history-table tbody tr:hover {
    background: #f9fafb;
}

/* ===== REPORTS SECTION ===== */
.reports-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.report-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
    text-align: center;
}

.report-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    color: #6366f1;
}

.report-card h3 {
    margin-bottom: 10px;
    color: #374151;
}

.report-card p {
    color: #6b7280;
    margin-bottom: 15px;
}

.report-actions {
    display: flex;
    gap: 10px;
}

.report-actions button {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.report-actions button:first-child {
    background: #6366f1;
    color: white;
}

.report-actions button:first-child:hover {
    background: #4f46e5;
}

.report-actions button:last-child {
    background: #16a34a;
    color: white;
}

.report-actions button:last-child:hover {
    background: #15803d;
}

.custom-report-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.custom-report-section h2 {
    margin-bottom: 20px;
    color: #374151;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #374151;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.form-actions button {
    padding: 12px 24px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.form-actions button:hover {
    background: #4f46e5;
}

.quick-downloads {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.quick-downloads h2 {
    margin-bottom: 20px;
    color: #374151;
}

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

.download-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: #f9fafb;
    border-radius: 8px;
    text-decoration: none;
    color: #374151;
    transition: all 0.3s ease;
}

.download-link:hover {
    background: #f3f4f6;
    transform: translateY(-1px);
}

.download-link i {
    font-size: 2rem;
    color: #6366f1;
}

.download-link h4 {
    margin-bottom: 5px;
    color: #374151;
}

.download-link p {
    font-size: 0.85rem;
    color: #6b7280;
    margin: 0;
}

/* ===== DEVICES MANAGEMENT SECTION ===== */
.devices-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.device-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-bottom: 10px;
}

.device-status.online {
    background: #16a34a;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
}

.device-status.offline {
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.3);
}

.device-status.partial {
    background: #f59e0b;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.3);
}

.device-icon {
    font-size: 2rem;
    color: #6366f1;
    margin-bottom: 15px;
}

.device-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.device-controls .btn-small {
    flex: 1;
    padding: 8px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.device-controls .btn-small:hover {
    background: #4f46e5;
}

.device-controls .btn-small:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.other-devices-detail-sidebar {
    margin: 15px 0;
}

.device-item-sidebar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.9rem;
}

.device-toggle-sidebar {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== AUTOMATION SECTION ===== */
.automation-container {
    margin-top: 20px;
}

.automation-rule {
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

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

.rule-header i {
    margin-right: 10px;
    font-size: 1.2rem;
}

.rule-header h3 {
    margin: 0;
    color: #374151;
}

.automation-rule p {
    color: #6b7280;
    margin: 0;
}

.automation-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.emergency-btn {
    padding: 10px 15px;
    background: #dc2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.emergency-btn:hover {
    background: #b91c1c;
}

.shutdown-btn {
    padding: 10px 15px;
    background: #6b7280;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.shutdown-btn:hover {
    background: #4b5563;
}

.rules-table {
    margin-top: 15px;
    overflow-x: auto;
}

.ac-rules-table {
    width: 100%;
    border-collapse: collapse;
}

.ac-rules-table th,
.ac-rules-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #e5e7eb;
}

.ac-rules-table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.ac-rules-table tbody tr:hover {
    background: #f9fafb;
}

/* ===== TOGGLE SWITCH ===== */
.toggle-switch {
    position: relative;
    width: 50px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active {
    background: #10b981;
}

.toggle-slider {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.toggle-switch.active .toggle-slider {
    transform: translateX(26px);
}

/* ===== ALERTS SECTION ===== */
.alerts-container {
    margin-top: 20px;
}

.alert-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    background: white;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid;
}

.alert-item.warning {
    border-left-color: #f59e0b;
}

.alert-item.info {
    border-left-color: #3b82f6;
}

.alert-item.success {
    border-left-color: #10b981;
}

.alert-item i {
    font-size: 1.5rem;
    margin-top: 5px;
}

.alert-item.warning i {
    color: #f59e0b;
}

.alert-item.info i {
    color: #3b82f6;
}

.alert-item.success i {
    color: #10b981;
}

.alert-content {
    flex: 1;
}

.alert-content h4 {
    margin: 0 0 5px 0;
    color: #374151;
}

.alert-content p {
    margin: 0 0 10px 0;
    color: #6b7280;
}

.alert-time {
    font-size: 0.8rem;
    color: #9ca3af;
}

/* ===== SETTINGS SECTION ===== */
.settings-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.settings-group {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border: 1px solid #e5e7eb;
}

.settings-group h3 {
    margin-bottom: 15px;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.setting-item {
    margin: 15px 0;
}

.setting-item label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #374151;
}

.setting-item input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.9rem;
}

.setting-item:has(.toggle-switch) {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-item:has(.toggle-switch) label {
    margin-bottom: 0;
}

.connection-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
}

.connection-status.connected {
    background: #16a34a;
}

.connection-status.disconnected {
    background: #dc2626;
}

/* ===== CHART CONTAINER ===== */
.chart-container {
    background: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }
    
    .sidebar .sidebar-text {
        display: none;
    }
    
    .main-content {
        margin-left: 70px;
    }
    
    .sensor-grid,
    .status-grid,
    .device-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .reports-container,
    .devices-grid,
    .settings-container {
        grid-template-columns: 1fr;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card {
    animation: fadeIn 0.5s ease-out;
}

/* ===== UTILITY CLASSES ===== */
.text-center {
    text-align: center;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-10 {
    margin-top: 10px;
}

.hidden {
    display: none;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

/* ===== DARK MODE STYLES ===== */
/* Default is dark mode */
body {
    background: #1f2937;
    color: #f9fafb;
}

.main-content {
    background: #1f2937;
}

.card {
    background: #374151;
    border: 1px solid #4b5563;
    color: #f9fafb;
}

.subnav {
    background: #374151;
    border-bottom: 1px solid #4b5563;
    color: #d1d5db;
}

.sensor-card .title,
.status-card .title,
.device-card .title {
    color: #f9fafb;
}

.sensor-card .value,
.status-card .value {
    color: #ffffff;
}

.history-table-container,
.report-card,
.custom-report-section,
.quick-downloads,
.settings-group,
.automation-rule {
    background: #374151;
    border: 1px solid #4b5563;
    color: #f9fafb;
}

.history-table th {
    background: #4b5563;
    color: #f9fafb;
}

.history-table td {
    color: #e5e7eb;
}

.ac-unit,
.lamp-circuit {
    background: #4b5563;
    color: #f9fafb;
}

.download-link {
    background: #4b5563;
    color: #f9fafb;
}

.download-link:hover {
    background: #6b7280;
}

.download-link h4 {
    color: #f9fafb;
}

.download-link p {
    color: #d1d5db;
}

.alert-content h4 {
    color: #f9fafb;
}

.alert-content p {
    color: #e5e7eb;
}

.device-item-sidebar {
    color: #f9fafb;
}

.form-group label {
    color: #f9fafb;
}

.setting-item label {
    color: #f9fafb;
}

/* ===== LIGHT MODE STYLES ===== */
body.light-mode {
    background: #ffffff;
    color: #1f2937;
}

body.light-mode .main-content {
    background: #ffffff;
}

body.light-mode .card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: #1f2937;
}

body.light-mode .subnav {
    background: #f9fafb;
    border-bottom: 1px solid #d1d5db;
    color: #4b5563;
}

body.light-mode .sensor-card .title,
body.light-mode .status-card .title,
body.light-mode .device-card .title {
    color: #1f2937;
}

body.light-mode .sensor-card .value,
body.light-mode .status-card .value {
    color: #111827;
}

body.light-mode .history-table-container,
body.light-mode .report-card,
body.light-mode .custom-report-section,
body.light-mode .quick-downloads,
body.light-mode .settings-group,
body.light-mode .automation-rule {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    color: #1f2937;
}

body.light-mode .history-table th {
    background: #f3f4f6;
    color: #1f2937;
}

body.light-mode .history-table td {
    color: #374151;
}

body.light-mode .ac-unit,
body.light-mode .lamp-circuit {
    background: #f3f4f6;
    color: #1f2937;
}

body.light-mode .download-link {
    background: #f3f4f6;
    color: #1f2937;
}

body.light-mode .download-link:hover {
    background: #e5e7eb;
}

body.light-mode .download-link h4 {
    color: #1f2937;
}

body.light-mode .download-link p {
    color: #6b7280;
}

body.light-mode .alert-content h4 {
    color: #1f2937;
}

body.light-mode .alert-content p {
    color: #6b7280;
}

body.light-mode .device-item-sidebar {
    color: #1f2937;
}

body.light-mode .form-group label {
    color: #374151;
}

body.light-mode .setting-item label {
    color: #374151;
}

/* ===== NOTIFICATION STYLES ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    color: white;
    font-weight: 500;
    transition: all 0.3s ease;
}

.notification.success {
    background: #10b981;
}

.notification.warning {
    background: #f59e0b;
}

.notification.info {
    background: #3b82f6;
}

.notification.error {
    background: #ef4444;
}

.notification button {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.notification button:hover {
    background: rgba(255,255,255,0.2);
}

/* ===== UPDATING ANIMATION ===== */
.updating {
    opacity: 0.6;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

/* ===== STATUS PARTIAL ===== */
.status-partial {
    color: #f59e0b;
    font-weight: 600;
}

/* ===== EFFICIENCY INDICATORS ===== */
.efficiency {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.efficiency.excellent {
    background: #dcfce7;
    color: #166534;
}

.efficiency.good {
    background: #dbeafe;
    color: #1e40af;
}

.efficiency.average {
    background: #fef3c7;
    color: #92400e;
}

.efficiency.poor {
    background: #fee2e2;
    color: #991b1b;
}

/* ===== AC RULES TABLE HIGHLIGHTING ===== */
.ac-rules-table tbody tr.current-rule {
    background: #dbeafe !important;
    border-left: 4px solid #3b82f6;
}

.ac-rules-table tbody tr.current-rule td {
    font-weight: 600;
    color: #1e40af;
}

/* ===== DISABLED OVERLAY ===== */
.disabled-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    z-index: 10;
    pointer-events: none;
}

/* ===== GRADUAL MODE STYLES ===== */
.ac-gradual-mode-status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    background: #f0f9ff;
    border: 1px solid #0ea5e9;
}

.gradual-mode-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
    color: #0369a1;
}

.gradual-mode-content.active {
    color: #0369a1;
}

.gradual-mode-content.inactive {
    color: #6b7280;
}

.gradual-progress {
    margin: 10px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0f2fe;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 5px;
}

.progress-fill {
    height: 100%;
    background: #0ea5e9;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: #0369a1;
}

.gradual-info {
    margin: 10px 0;
}

.info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-size: 0.85rem;
}

.gradual-description {
    font-size: 0.8rem;
    color: #6b7280;
    font-style: italic;
    margin-top: 10px;
}

.gradual-active {
    animation: pulse 2s infinite;
}

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

/* ===== CONNECTION STATUS STYLES ===== */
.connection-status.connecting {
    background: #f59e0b;
    animation: blink 1s infinite;
}

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

/* ===== ENHANCED HOVER EFFECTS ===== */
.card:hover .card-icon {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.mini-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

.temp-btn:hover {
    transform: scale(1.05);
    transition: transform 0.2s ease;
}

/* ===== SIDEBAR ENHANCEMENTS ===== */
.sidebar ul li a {
    position: relative;
    overflow: hidden;
}

.sidebar ul li a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.sidebar ul li a:hover::before {
    left: 100%;
}

/* ===== LOADING STATES ===== */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== ENHANCED BUTTON STATES ===== */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

button:active {
    transform: scale(0.98);
}

/* ===== SMOOTH TRANSITIONS ===== */
* {
    transition: color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
}

/* ===== FOCUS STYLES ===== */
button:focus,
input:focus,
select:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ===== SCROLLBAR STYLES ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ===== DARK MODE SCROLLBAR ===== */
body.dark-mode ::-webkit-scrollbar-track {
    background: #374151;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #6b7280;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}