:root {
    --primary-red: #e63946;
    --soft-red: #ff6b6b;
    --pure-white: #ffffff;
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    --bg-gradient: linear-gradient(180deg, var(--soft-red) 0%, var(--pure-white) 500px, var(--pure-white) 100%);
    --login-gradient: linear-gradient(180deg, var(--soft-red) 0%, var(--pure-white) 100%);
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    min-height: 100vh;
    background: var(--bg-gradient);
    background-attachment: fixed;
}

body.login-body {
    background: var(--login-gradient);
    display: flex;
    flex-direction: column;
}

body.nav-body {
    padding-top: 80px;
}

h1, h2, h3, h4, .navbar-brand {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

.navbar-brand {
    color: var(--primary-red) !important;
}

/* Login Page */
.login-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: var(--pure-white);
    border: none;
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.form-control {
    border-radius: 10px;
    padding: 12px 15px;
    border: 1px solid #eee;
    background-color: #f8f9fa;
}

.form-control:focus {
    box-shadow: none;
    border-color: var(--soft-red);
    background-color: #fff;
}

.btn-primary {
    background-color: var(--primary-red);
    border: none;
    border-radius: 10px;
    padding: 12px;
    font-weight: 600;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: #d62828;
    transform: translateY(-2px);
}

.brand-logo {
    color: var(--primary-red);
    font-size: 2rem;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

/* Listing Pages (Sensors & Departments) */
.sensor-card, .dept-card {
    background: var(--pure-white);
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.sensor-card:hover, .dept-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.1);
}

.status-badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

.status-active { background-color: #2ecc71; box-shadow: 0 0 8px #2ecc71; }
.status-warning { background-color: #f1c40f; box-shadow: 0 0 8px #f1c40f; }
.status-error { background-color: #da00ae; box-shadow: 0 0 8px #e73cbf; }
.status-critical { background-color: #e74c3c; box-shadow: 0 0 8px #e74c3c; }

.btn-view {
    background-color: var(--primary-red);
    border: none;
    border-radius: 10px;
    padding: 8px 16px;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-block;
    transition: background-color 0.2s;
}

.btn-view:hover {
    background-color: #d62828;
    color: white;
}

.sensor-id, .dept-id {
    font-size: 0.75rem;
    color: #adb5bd;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-label {
    font-size: 0.85rem;
    color: #6c757d;
}

.stats-value {
    font-size: 0.85rem;
    font-weight: 600;
    color: #212529;
}

/* Detail Page */
.metric-card {
    background: var(--pure-white);
    border: none;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 24px;
    height: 100%;
}

.detail-large-card {
    background: var(--pure-white);
    border: none;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.08);
    overflow: hidden;
}

.detail-header {
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    padding: 30px;
}

.detail-body {
    padding: 30px;
}

.status-pill {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.pill-active { background: #e8f5e9; color: #2e7d32; }

.metric-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #212529;
}

.metric-unit {
    font-size: 0.9rem;
    color: #6c757d;
    font-weight: 400;
}

.btn-back {
    color: #6c757d;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.btn-back:hover {
    color: var(--primary-red);
}

.log-entry {
    border-left: 3px solid #eee;
    padding-left: 15px;
    margin-bottom: 15px;
    position: relative;
}

.log-time {
    font-size: 0.75rem;
    color: #adb5bd;
    display: block;
}

.log-msg {
    font-size: 0.9rem;
    color: #495057;
}

.log-entry.error { border-left-color: var(--primary-red); }
.log-entry.success { border-left-color: #2ecc71; }

/* Utilities */
.text-muted-50 {
    color: rgba(108, 117, 125, 0.7);
}

/* Admin Sidebar Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--pure-white);
    border-right: 1px solid rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 1030;
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid rgba(0,0,0,0.02);
}

.sidebar-content {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid rgba(0,0,0,0.02);
}

.admin-main {
    flex: 1;
    margin-left: 280px;
    padding: 2rem;
    background: var(--bg-gradient);
    background-attachment: fixed;
}

.nav-link-admin {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0.8rem 1rem;
    color: #495057;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.nav-link-admin:hover {
    background: #f8f9fa;
    color: var(--primary-red);
}

.nav-link-admin.active {
    background: #fff5f5;
    color: var(--primary-red);
}

.nav-link-admin i {
    font-size: 1.2rem;
}

.sidebar-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #adb5bd;
    font-weight: 700;
    padding: 0 1rem 0.8rem;
    margin-top: 1rem;
}

@media (max-width: 991.98px) {
    .sidebar {
        margin-left: -280px;
    }
    .sidebar.show {
        margin-left: 0;
    }
    .admin-main {
        margin-left: 0;
    }
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1025;
        display: none;
    }
    .sidebar-overlay.show {
        display: block;
    }
}

/* Consolidated Styles from HTML Files */

/* Scoped Table Styles from departments_list.html */
.table-card {
    background: var(--pure-white);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.05);
    overflow: hidden;
    border: none;
}

.table-card .table {
    margin-bottom: 0;
}

.table-card .table thead th {
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
    padding: 1.25rem 1rem;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #6c757d;
    font-weight: 700;
}

.table-card .table tbody td {
    padding: 1.25rem 1rem;
    vertical-align: middle;
    color: #495057;
    font-weight: 500;
    border-bottom: 1px solid #f8f9fa;
}

.table-card .table tbody tr:last-child td {
    border-bottom: none;
}

.table-card .table tbody tr {
    transition: background-color 0.2s;
}

.table-card .table tbody tr:hover {
    background-color: #fcfcfc;
}

.action-btn {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
    background: #f8f9fa;
}

.btn-edit { color: #3498db; }
.btn-edit:hover { background: #ebf5fb; color: #2980b9; }
.btn-delete { color: #e74c3c; }
.btn-delete:hover { background: #fdedec; color: #c0392b; }

.status-badge-table {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-warning { background: #fffde7; color: #f57f17; }
.badge-error { background: #ffebee; color: #c62828; }

.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.dot-active { background: #2e7d32; box-shadow: 0 0 6px #2e7d32; }
.dot-warning { background: #f57f17; box-shadow: 0 0 6px #f57f17; }
.dot-error { background: #c62828; box-shadow: 0 0 6px #c62828; }

/* Styles from add-department.html */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #eee;
}

.icon-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #6c757d;
    cursor: pointer;
    border-radius: 10px;
    transition: all 0.2s ease;
    background: white;
    border: 1px solid transparent;
}

.icon-item:hover {
    background: #fff5f5;
    color: var(--primary-red);
    border-color: var(--soft-red);
}

.icon-item.active {
    background: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.3);
}

.form-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

/* Styles from display-data.html (Renamed conflict) */
.temp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 8px;
    margin-top: 15px;
}

.temp-cell {
    background: linear-gradient(135deg, var(--soft-red) 0%, var(--primary-red) 100%);
    color: white;
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.temp-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.temp-label {
    font-size: 10px;
    opacity: 0.9;
    margin-bottom: 3px;
}

.metric-change {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-top: 8px;
}

.metric-up { background: #c6f6d5; color: #22543d; }
.metric-warning { background: #feebc8; color: #7c2d12; }
.metric-danger { background: #fed7d7; color: #742a2a; }
.metric-down { background: #fed7d7; color: #742a2a; }

.anomaly-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
}

.anomaly-badge.critical { background: #fed7d7; color: #742a2a; }
.anomaly-badge.warning { background: #feebc8; color: #7c2d12; }
.anomaly-badge.info { background: #bee3f8; color: #2c5282; }

/* Renamed from .status-badge to avoid conflict with dot style */
.status-badge-pill {
    background: #48bb78;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.status-badge-pill-offline {
    background: #d80404;
    color: white;
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

#statusText {
    white-space: nowrap;
}

.pulse {
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.analysis-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    background: #f8f9fa;
    padding: 6px;
    border-radius: 50px;
    width: fit-content;
    border: 1px solid #eee;
}

.tab-btn {
    padding: 8px 20px;
    background: transparent;
    border: none;
    border-radius: 50px;
    color: #6c757d;
    font-weight: 600;
    font-size: 13px;
    font-family: 'Outfit', sans-serif;
    transition: all 0.3s ease;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--primary-red);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(230, 57, 70, 0.2);
}

.tab-btn:hover:not(.active) {
    background: rgba(230, 57, 70, 0.05);
    color: var(--primary-red);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Helper Class for Background Overrides */
.bg-white-important {
    background: #ffffff !important;
}




/* Ensure the alert has a transition property */
div.alert-container {
    opacity: 1;
    transition: opacity 0.5s ease-out; /* The fade takes 0.5 seconds */
}

/* This class triggers the invisible state */
div.alert-container.fade-out {
    opacity: 0;
}

.chart-container {
    min-height: 250px;
    width: 100%;
}