/* styles.css */

/* Reset and Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    color: #333;
    margin: 0;
    padding: 0;
}

/* Container */
.container {
    display: flex;
    flex-direction: row;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: #f4f4f4;
    padding: 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 99;
    padding-top: 60px;
    transition: transform 0.3s ease;
}

.sidebar h2 {
    margin-bottom: 20px;
}

.sidebar ul {
    list-style-type: none;
}

.sidebar ul li {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #ddd;
}

.sidebar ul li:hover,
.sidebar ul li.active {
    background-color: #e2e2e2;
}

/* Main Content */
.main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    margin-left: 250px;
    transition: margin-left 0.3s ease;
    padding-top: 60px;
}

.main.expanded {
    margin-left: 0;
}

.chart-toggle {
    display: flex;
    margin-bottom: 20px;
}

.chart-toggle button {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    cursor: pointer;
}

.chart-toggle button.active {
    background-color: #3498db;
    color: white;
}

/* Chart Container */
.chart-container {
    width: 100%;
    height: 400px;
    margin-bottom: 20px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Loading Indicator */
.loading {
    text-align: center;
    font-size: 18px;
    margin-top: 20px;
}

/* Error Message */
.error-message {
    color: red;
    text-align: center;
    margin-top: 20px;
}

/* Modal Styles */
.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.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    max-width: 500px;
    width: 90%;
    position: relative;
}

.close {
    color: #aaa;
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 28px;
    cursor: pointer;
}

.modal-content h2 {
    margin-top: 0;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
}

.modal-content button {
    width: 100%;
    padding: 10px;
    background-color: #3498db;
    color: white;
    border: none;
    cursor: pointer;
}

.modal-content button:hover {
    background-color: #2980b9;
}

/* Hamburger Menu Icon */
.hamburger {
    font-size: 24px;
    cursor: pointer;
    padding: 15px;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 0 0 0 4px;
    transition: all 0.3s ease;
}

.hamburger:hover {
    background: #2980b9;
}

.gear-icon {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.hamburger.active .gear-icon {
    transform: rotate(45deg);
}

/* Side Menu */
.side-menu {
    height: 100%;
    width: 0;
    position: fixed;
    z-index: 9;
    top: 0;
    right: 0;
    background-color: #ffffff;
    overflow-x: hidden;
    transition: 0.3s ease;
    border-left: 1px solid #ccc;
    box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
}

.side-menu.visible {
    width: 300px;
}

.side-menu-content {
    padding: 40px 30px;
}

.side-menu h2 {
    margin-top: 0;
    margin-bottom: 30px;
    color: #2c3e50;
    font-size: 24px;
}

/* Menu Sections */
.menu-section {
    margin-bottom: 30px;
}

.menu-section label {
    display: block;
    margin-bottom: 10px;
    color: #34495e;
    font-weight: 500;
}

.menu-section select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #f8f9fa;
}

#menuAddDeviceBtn,
#menuLogoutBtn {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    margin-bottom: 15px;
    cursor: pointer;
    border-radius: 4px;
    border: none;
    transition: background-color 0.3s ease;
}

#menuAddDeviceBtn {
    background-color: #3498db;
    color: white;
}

#menuAddDeviceBtn:hover {
    background-color: #2980b9;
}

#menuLogoutBtn {
    background-color: #e74c3c;
    color: white;
}

#menuLogoutBtn:hover {
    background-color: #c0392b;
}

/* Time Scale Selector */
.time-scale-selector {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 50px; /* Add margin to avoid toggle button */
}

.time-scale-selector label {
    font-weight: bold;
}

.time-scale-selector select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
}

.time-scale-selector select:hover {
    border-color: #3498db;
}

/* Media Queries for Responsive Design */

/* Mobile Styles */
@media (max-width: 768px) {
    .sidebar {
        width: 250px;
        transform: translateX(-100%);
        position: fixed;
        z-index: 99;
        box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    .sidebar.hidden {
        transform: translateX(-100%);
    }

    .sidebar:not(.hidden) {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
        padding: 20px;
        padding-top: 60px;
        width: 100%;
    }

    .main.expanded {
        margin-left: 0;
    }

    .sidebar-toggle {
        position: fixed;
        left: 10px;
        top: 10px;
        z-index: 1000;
        background: #3498db;
        color: white;
        border: none;
        border-radius: 4px;
        padding: 8px 12px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        min-width: 40px;
        min-height: 40px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }

    .sidebar-toggle:hover {
        background: #2980b9;
    }

    .chart-toggle {
        flex-direction: column;
    }

    .chart-toggle button {
        margin-bottom: 10px;
    }

    /* Adjust font sizes */
    body {
        font-size: 16px;
    }

    .modal-content {
        margin: 10% auto;
    }

    /* Adjust chart container */
    .chart-container {
        max-width: 100%;
    }

    .time-scale-selector {
        margin-left: 50px;
    }

    /* Add overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 98;
    }

    .sidebar-overlay.visible {
        display: block;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Sidebar */
    .sidebar {
        width: 200px;
    }

    /* Main Content */
    .main {
        padding: 15px;
    }

    /* Adjust font sizes */
    body {
        font-size: 17px;
    }
}

/* Overlay for Sidebar (optional) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 8;
    display: none;
}

.sidebar-overlay.visible {
    display: block;
}

.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
}

#dailyIncrementsTable {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

#dailyIncrementsTable th,
#dailyIncrementsTable td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#dailyIncrementsTable th {
    background-color: #f5f5f5;
    font-weight: 600;
    color: #333;
}

#dailyIncrementsTable tr:hover {
    background-color: #f9f9f9;
}

#dailyIncrementsTable td:nth-child(4) {
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

#dailyIncrementsTable td:nth-child(4) span {
    font-size: 1.2em;
    font-weight: bold;
}

#dailyIncrementsTable td:nth-child(4):not(:empty) {
    color: #2c3e50;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: fixed;
    left: 20px;
    top: 20px;
    z-index: 100;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    min-width: 40px;
    min-height: 40px;
}

.sidebar-toggle:hover {
    background: #2980b9;
}

.toggle-icon {
    font-size: 20px;
    line-height: 1;
}

/* Sidebar States */
.sidebar.hidden {
    transform: translateX(-100%);
}

.device-info {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: 8px 12px;
}

.device-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.last-seen {
    font-size: 0.8em;
    color: #666;
    font-style: italic;
}

#deviceList li {
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #eee;
}

#deviceList li:hover {
    background-color: #f5f5f5;
}

#deviceList li.active {
    background-color: #e3f2fd;
}

#deviceList li.active .device-name {
    color: #1976d2;
}

#deviceList li.active .last-seen {
    color: #1976d2;
}

/* Alarm Management Styles */
.alarms-container {
    padding: 20px;
}

.alarms-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.alarms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.alarm-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 15px;
    transition: all 0.3s ease;
}

.alarm-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.alarm-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.alarm-card-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

.alarm-card-status {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
}

.alarm-card-status.active {
    background: #28a745;
    color: white;
}

.alarm-card-status.inactive {
    background: #6c757d;
    color: white;
}

.alarm-card-description {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 10px;
}

.alarm-card-details {
    margin-bottom: 15px;
}

.alarm-card-details strong {
    color: #333;
}

.alarm-card-actions {
    display: flex;
    gap: 10px;
}

.alarm-history {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 20px;
}

.alarm-history h3 {
    margin-top: 0;
    margin-bottom: 15px;
}

.history-item {
    border-left: 4px solid #dc3545;
    padding: 10px 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 0 4px 4px 0;
}

.history-item:hover {
    background: #f1f3f5;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.history-item-title {
    font-weight: 600;
    margin: 0;
}

.history-item-time {
    color: #666;
    font-size: 0.9em;
}

.history-item-details {
    font-size: 0.9em;
    color: #555;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
}

.form-group textarea {
    resize: vertical;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.btn-primary,
.btn-secondary {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 500px;
    margin: 50px auto;
    padding: 20px;
    border-radius: 8px;
    position: relative;
}

.close {
    position: absolute;
    right: 20px;
    top: 15px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close:hover {
    color: #333;
}
