:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --card-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --danger-color: #f43f5e;
    /* For hot temp if needed */
    --success-color: #22c55e;

    --font-main: 'Outfit', sans-serif;
}

* {
    box-sizing: border_box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    font-family: var(--font-main);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* Layout: Auth (Centered) */
body.auth-layout {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Layout: Dashboard (Sidebar + Content) */
body.dashboard-layout {
    display: flex;
    flex-direction: row;
    overflow-x: hidden;
}

/* --- Dashboard Components (Extracted from base.html) --- */
.sidebar {
    width: 280px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid var(--card-border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.main-content {
    flex-grow: 1;
    padding: 20px;
    position: relative;
    width: 100%;
}

.aggregator-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

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

.aggregator-item {
    padding: 12px 15px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

.aggregator-item:hover,
.aggregator-item.active {
    background: var(--accent-color);
    color: #0f172a;
}

.sensor-sublist {
    list-style: none;
    padding: 0;
    margin-left: 35px;
    display: none;
    flex-direction: column;
    gap: 5px;
    margin-top: 5px;
}

.aggregator-item.expanded+.sensor-sublist {
    display: flex;
}

.sensor-item {
    padding: 8px 12px 8px 25px;
    font-size: 0.9em;
    color: var(--text-secondary);
    cursor: pointer;
    position: relative;
}

.sensor-item::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-color);
    opacity: 0.6;
}

.sensor-item:hover {
    color: var(--text-primary);
}

.sensor-item:hover::before {
    opacity: 1;
}

.menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: white;
    font-size: 1.2rem;
    padding: 8px 12px;
    cursor: pointer;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        height: 100vh;
        width: 280px;
        top: 0;
        left: 0;
        z-index: 1001;
        transform: translateX(-100%);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        transition: transform 0.3s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        z-index: 1000;
    }

    .sidebar.open+.sidebar-overlay {
        display: block;
    }

    .menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        padding-top: 80px;
        width: 100%;
        z-index: 1;
        position: relative;
    }
}

/* Responsive pour smartphones - Portrait */
@media (max-width: 768px) {

    /* Réduire le décalage des capteurs sur mobile */
    .sensor-sublist {
        margin-left: 25px;
    }

    .sensor-item {
        padding: 8px 10px 8px 20px;
        font-size: 0.85em;
    }

    .sensor-item::before {
        left: 8px;
        width: 5px;
        height: 5px;
    }
}

/* Responsive pour smartphones - Paysage */
@media (max-width: 926px) and (orientation: landscape) {
    .main-content {
        padding-top: 70px;
    }
}

.nav-footer {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-link {
    text-decoration: none;
    color: var(--text-secondary);
    padding: 10px;
    border-radius: 8px;
    display: block;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.app-container {
    width: 100%;
    max-width: 480px;
    /* iPhone width constraint */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    text-align: center;
    margin-bottom: 10px;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--success-color);
    font-weight: 600;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--success-color);
    border-radius: 50%;
    animation: blink 2s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }

    100% {
        opacity: 1;
    }
}

h1 {
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -1px;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-weight: 400;
    font-size: 1rem;
    color: var(--text-secondary);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.auth-card {
    background: var(--card-bg);
    /* Or darker slate if preferred */
    background-color: #1e293b;
    /* Keep original login look */
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    width: 100%;
    max-width: 400px;
}

.current-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.temp-display {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 20px;
}

.icon-large {
    font-size: 2rem;
    color: var(--accent-color);
    margin-top: 15px;
}

.value {
    font-size: 5rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -2px;
}

.unit {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 10px;
}

.meta-info {
    display: flex;
    gap: 20px;
    font-size: 1.1rem;
    color: var(--text-secondary);
}

.chart-card h3 {
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 20px;
    font-weight: 600;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
}

footer {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: auto;
    padding-bottom: 10px;
    opacity: 0.5;
}

/* Time Controls */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-card h3 {
    margin-bottom: 0;
}

.time-controls {
    display: flex;
    gap: 5px;
    background: rgba(255, 255, 255, 0.05);
    padding: 4px;
    border-radius: 12px;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: var(--font-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.time-btn.active {
    background: var(--accent-color);
    color: #0f172a;
    font-weight: 600;
}

.time-btn:hover:not(.active) {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.time-btn.static-btn {
    cursor: default;
    opacity: 0.7;
    font-weight: 600;
    color: var(--accent-color);
}

.time-btn.static-btn:hover {
    background: transparent;
    color: var(--accent-color);
}

/* Action Button Styles */
.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
    padding: 5px;
}

.action-btn:hover {
    color: var(--accent-color);
    transform: rotate(45deg);
}


/* --- Form Elements --- */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    background-color: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-main);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    /* iOS Reset */
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1);
}

button.primary-btn,
button[type="submit"] {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    margin-top: 10px;
}

button.primary-btn:hover,
button[type="submit"]:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.error-msg {
    color: var(--danger-color);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 1rem;
    display: none;
}

/* ================================================================
   DARK THEME TEXT OVERRIDES
   Force Bootstrap/Material Dashboard text classes to be readable
   on the dark card backgrounds used by this dashboard.
   ================================================================ */

/* Headers in cards */
.card-header h6,
.card-header .h6,
.card .card-header h5,
.card .card-header h4 {
    color: #f0f4f8 !important;
}

/* text-dark used by Material Dashboard for headings */
.text-dark {
    color: #f0f4f8 !important;
}

/* text-secondary used for subtitles, meta info */
.text-secondary {
    color: #94a3b8 !important;
}

/* General text in card bodies */
.card-body p,
.card-body span,
.card-body small,
.card-body label {
    color: #cbd5e1;
}

/* Timeline content text */
.timeline-content h6,
.timeline-content p,
.timeline-content span {
    color: #f0f4f8 !important;
}

.timeline-content p.text-xs,
.timeline-content .text-secondary {
    color: #94a3b8 !important;
}

/* Progress bars labels */
.progress-percentage .text-xs,
.progress-info .text-xs {
    color: #e2e8f0 !important;
}

/* Table text in dark cards */
.card table,
.card td,
.card th {
    color: #e2e8f0;
}

/* Form labels in cards */
.card label {
    color: #94a3b8;
}

/* Alert overrides to stay readable */
.alert {
    color: inherit;
}

/* Badge override – keep badge text always white */
.badge {
    color: #fff !important;
}