/* General styles for body and html */
body, html {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: #f5f5f5;
    height: 100%; /* Ensure body and html take up full height */
}

/* Centering for login page */
body.login-page {
    display: flex; /* Use flexbox for centering */
    justify-content: center;
    align-items: center;
}

body.login-page .main-content {
    margin-left: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100%; /* Ensure the main-content takes the full width */
    background-color: #f5f5f5;
}

/* Restore normal layout for other pages */
body:not(.login-page) .sidebar {
    display: block;
    width: 250px;
    height: 100vh;
    background-color: #2c3e50;
    position: fixed;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    z-index: 900;
    transition: transform 0.3s ease;
    will-change: transform;
    overflow-y: auto;
}

body:not(.login-page) .main-content {
    margin-left: 250px;
    padding: 20px;
}

.login-container {
    background-color: #2c3e50; /* Darker background color */
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container .logo img {
    width: 100px; /* Adjusted width */
    margin-bottom: 20px;
}

.login-container h1 {
    font-size: 24px;
    margin-bottom: 10px;
    color: white; /* Change text color to white */
}

.login-container p {
    font-size: 14px;
    color: #aaa; /* Change text color to light gray */
    margin-bottom: 30px;
}

.login-container form {
    display: flex;
    flex-direction: column;
}

.login-container input[type="text"], 
.login-container input[type="password"] {
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.login-container .remember-me {
    display: flex;
    align-items: center;
    margin-bottom: 20px;
    color: white; /* Change text color to white */
}

.login-container .remember-me input {
    margin-right: 10px;
}

.login-container .remember-me label {
    font-size: 14px;
    color: #aaa; /* Change text color to light gray */
}

.login-container button {
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

.login-container button:hover {
    background-color: #2980b9;
}

.login-container .forgot-password {
    margin-top: 15px;
}

.login-container .forgot-password a {
    color: #3498db;
    font-size: 14px;
    text-decoration: none;
}

.login-container .forgot-password a:hover {
    text-decoration: underline;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.sidebar-toggle {
    display: none;
    align-items: center;
    gap: 6px;
    border: 1px solid #bdc3c7;
    background-color: #ffffff;
    color: #2c3e50;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 800;
}

body.sidebar-open .sidebar-backdrop {
    display: block;
}

body.sidebar-open {
    overflow: hidden;
}


/* Page headers & device grid */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.device-count {
    font-weight: 500;
    color: #2c3e50;
}

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

.device-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(44, 62, 80, 0.08);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.device-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.device-card-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.device-last-seen {
    margin: 4px 0 0;
    color: #6b7280;
    font-size: 0.9rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-pill .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: currentColor;
}

.status-pill.online {
    background-color: rgba(76, 175, 80, 0.12);
    color: #1b5e20;
}

.status-pill.offline {
    background-color: rgba(244, 67, 54, 0.12);
    color: #b71c1c;
}

.interval-form {
    background-color: #f8fafc;
    border-radius: 10px;
    padding: 15px;
    display: grid;
    gap: 12px;
}

.interval-field label {
    font-weight: 500;
    color: #2c3e50;
}

.interval-controls {
    display: flex;
    gap: 10px;
    margin: 6px 0;
}

.interval-controls input,
.interval-controls select {
    flex: 1;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 0.95rem;
}

.interval-current {
    font-size: 0.85rem;
    color: #6b7280;
}

.interval-feedback {
    font-size: 0.85rem;
    color: #1b5e20;
}

.interval-feedback.error {
    color: #b71c1c;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.9rem;
}

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

.btn-primary:hover {
    background-color: #2c80b4;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #1f2937;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-link {
    color: #2563eb;
    padding: 0;
    background: transparent;
}

.card-actions {
    display: flex;
    justify-content: flex-end;
}

.advanced-toggle,
.debug-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    background: transparent;
    font-weight: 500;
    color: #1f2937;
    cursor: pointer;
    padding: 8px 0;
}

.advanced-toggle .chevron,
.debug-toggle .chevron {
    transition: transform 0.2s ease;
}

.advanced-toggle.expanded .chevron,
.debug-toggle.expanded .chevron {
    transform: rotate(180deg);
}

.advanced-details {
    border-top: 1px solid #e5e7eb;
    padding-top: 10px;
}

.advanced-details dl {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 0 0 10px;
}

.advanced-details dl div {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.advanced-details dt {
    font-size: 0.75rem;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.advanced-details dd {
    margin: 0;
    font-weight: 500;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    overflow-wrap: anywhere;
    background-color: #f8fafc;
    border-radius: 4px;
    padding: 6px 8px;
}

.debug-block {
    background-color: #0f172a;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    overflow-x: auto;
}

/* Sensor data filters */
.filter-panel {
    background-color: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(44, 62, 80, 0.08);
    margin-bottom: 25px;
}

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

.filter-field label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: #1f2937;
}

.filter-field select,
.filter-field input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

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

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

.sensor-table th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    color: #6b7280;
}

.sensor-table tbody tr:hover {
    background-color: #f8fafc;
}

@media (max-width: 768px) {
    .interval-controls {
        flex-direction: column;
    }

    .device-card-header {
        flex-direction: column;
    }

    .filter-actions {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* Container for the main content */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.organization-groups {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.organization-group h2 {
    margin-bottom: 12px;
    color: #1f2a37;
    font-size: 1.4rem;
}

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

/* Header styles */
.header {
    background-color: white;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Establishment information styles */
.establishment-info {
    margin-bottom: 20px;
}

.establishment-name {
    font-size: 24px;
    font-weight: 500;
    color: #333;
}

.establishment-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    margin-left: 10px;
}

.status-low { background-color: #ff4d4d; color: white; }
.status-medium { background-color: #ffd700; color: black; }
.status-high { background-color: #4CAF50; color: white; }

.establishment-address {
    color: #666;
    font-size: 14px;
}

/* Action bar styles */
.action-bar {
    margin: 20px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#trigger-image {
    background-color: #4CAF50;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
}

#trigger-image:hover {
    background-color: #45a049;
}

/* Table styles */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

th, td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
    font-weight: 500;
}

/* Stock status styles */
.stock-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

/* Button styles */
.view-btn, .delete-btn, .submit-btn {
    background-color: #28374b;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
}

.delete-btn {
    background-color: #e74c3c;
}

.submit-btn {
    background-color: #3498db;
    padding: 10px 20px;
    margin-top: 10px;
}

.view-btn:hover, .delete-btn:hover, .submit-btn:hover {
    background-color: #1a252f;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 600px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}

#modal-image {
    width: 100%;
    height: auto;
}

/* Sidebar styles */
.sidebar {
    width: 250px;
    height: 100vh;
    background-color: #2c3e50;
    position: fixed;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 0;
    z-index: 900;
    transition: transform 0.3s ease;
    will-change: transform;
    overflow-y: auto;
}

.sidebar .logo {
    text-align: center;
    margin-bottom: 30px;
}

.sidebar .logo img {
    width: 80%;
    height: auto;
}

.sidebar .menu {
    flex-grow: 1;
}

.sidebar .menu .menu-item {
    display: block;
    color: #ecf0f1;
    padding: 15px 30px;
    text-decoration: none;
    font-size: 18px;
    cursor: pointer;
    position: relative;
}

.sidebar .menu .menu-item:hover,
.sidebar .menu .menu-item.active {
    background-color: #34495e;
}

.sidebar .submenu {
    padding-left: 20px;
    display: none;
}

.sidebar .submenu .submenu-item {
    display: block;
    color: #bdc3c7;
    padding: 10px 30px;
    text-decoration: none;
    font-size: 16px;
    cursor: pointer;
    position: relative;
}

.sidebar .submenu .submenu-item:hover {
    background-color: #3d566e;
}

.sidebar .subsubmenu {
    padding-left: 20px;
    display: none;
}

.sidebar .subsubmenu .subsubmenu-item {
    display: block;
    color: #95a5a6;
    padding: 8px 30px;
    text-decoration: none;
    font-size: 14px;
}

.sidebar .subsubmenu .subsubmenu-item:hover {
    background-color: #4a637d;
}

.arrow {
    position: absolute;
    right: 20px;
    transition: transform 0.3s;
}

.arrow.rotate {
    transform: rotate(180deg);
}

/* Main content styles */
.main-content {
    margin-left: 250px;
    padding: 20px;
}

/* Navbar styles */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #ecf0f1;
    padding: 10px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

.navbar input[type="text"] {
    width: 50%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.navbar .user-menu {
    display: flex;
    align-items: center;
}

.navbar .user-menu img.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-right: 20px;
}

.navbar .user-menu a {
    color: #2c3e50;
    text-decoration: none;
    font-weight: 500;
}

.navbar .user-menu a:hover {
    text-decoration: underline;
}

@media (max-width: 1024px) {
    body:not(.login-page) .sidebar {
        width: 80%;
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
    }

    body.sidebar-open:not(.login-page) .sidebar {
        transform: translateX(0);
    }

    body:not(.login-page) .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .sidebar-toggle {
        display: inline-flex;
    }

    .navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .navbar input[type="text"] {
        width: 100%;
    }

    .navbar .user-menu {
        width: 100%;
        justify-content: space-between;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .device-card {
        padding: 16px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .establishment-cards, .device-cards {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .navbar .user-menu {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .navbar .user-menu img.profile-pic {
        margin-right: 0;
    }

    .card {
        padding: 16px;
    }

    .btn,
    .btn-sm {
        width: 100%;
    }
}

/* Admin section styles */
.admin-section {
    margin-top: 40px;
}

.admin-section h2 {
    margin-bottom: 20px;
}

.admin-section form {
    display: flex;
    flex-direction: column;
}

.admin-section form label {
    margin-bottom: 5px;
    font-weight: 500;
}

.admin-section form input,
.admin-section form select {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.admin-section form button {
    align-self: flex-start;
}

/* Card styles for establishments and devices */
.establishment-cards, .device-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 20px;
}

.card {
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 100%;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card h2 {
    font-size: 1.5em;
    margin: 0 0 10px;
}

.card p {
    font-size: 1em;
    color: #666;
}

.card a {
    text-decoration: none;
    color: #3498db;
    font-weight: 500;
}

.card a:hover {
    text-decoration: underline;
}

/* Status indicator styles */
.status-indicator {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    margin: 10px 0;
}

.status-low {
    background-color: #ff4d4d;
    color: white;
}

.status-medium {
    background-color: #ffd700;
    color: black;
}

.status-high {
    background-color: #4CAF50;
    color: white;
}

/* Button styles */
.view-btn {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
}

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

/* Flash messages styles */
.flash-messages {
    list-style-type: none;
    padding: 0;
    margin-bottom: 15px;
}

.flash-message {
    padding: 10px;
    background-color: #e74c3c;
    color: white;
    border-radius: 4px;
    margin-bottom: 10px;
}
