:root {
    /* Palette de couleurs Ultra-Premium Dark Mode */
    --bg-color: #0B0E14;
    /* Noir profond légèrement bleuté */
    --card-bg: rgba(20, 25, 35, 0.4);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;

    /* Couleurs Néon Vives */
    --temp-color: #FF2A5F;
    /* Rouge Rosé Néon */
    --hum-color: #00F0FF;
    /* Cyan Lumineux */
    --sol-color: #FFD700;
    /* Or Étincelant */
    --sys-color: #00FF88;
    /* Vert Cyber */

    --alert-color: #FF003C;
    --warn-color: #FF9900;

    --primary-color: #4A00E0;
    /* Dégradé Violet/Bleu */
    --primary-gradient: linear-gradient(135deg, #8E2DE2, #4A00E0);
    --primary-hover: #8E2DE2;
    --success-color: #00E676;

    /* Glassmorphism Borders & Shadows */
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem;

    /* Animated Mesh Gradient Background */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(142, 45, 226, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(0, 240, 255, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
}

header {
    text-align: center;
    margin-bottom: 3rem;
    margin-top: 1rem;
    animation: fadeInDown 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, #FFFFFF 0%, #A0B0D0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    filter: drop-shadow(0 2px 10px rgba(255, 255, 255, 0.1));
}

p.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 400;
    letter-spacing: 0.02em;
}

/* Navigation Globale "Pill" */
.navigation {
    display: inline-flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    margin-top: 2rem;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem;
    border-radius: 3rem;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.navigation a {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.7rem 1.8rem;
    border-radius: 2rem;
    background: transparent;
    transition: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    font-weight: 600;
    font-size: 0.95rem;
}

.navigation a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.navigation a.active {
    color: white;
    background: var(--primary-gradient);
    box-shadow: 0 0 20px rgba(142, 45, 226, 0.4);
}

#device-selector {
    padding: 0.7rem 1.2rem;
    border-radius: 2rem;
    background: rgba(10, 15, 25, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    margin-right: 10px;
    outline: none;
    transition: all 0.3s;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px top 50%;
    padding-right: 35px;
}

#device-selector:hover,
#device-selector:focus {
    border-color: rgba(142, 45, 226, 0.6);
    box-shadow: 0 0 15px rgba(142, 45, 226, 0.2);
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes pulseGlow {
    0% {
        box-shadow: 0 0 0 0 var(--sys-color);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(0, 255, 136, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(0, 255, 136, 0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================= */
/* DASHBOARD STYLES (arduino_dashboard.html) */
/* ========================================= */

.main-layout {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 1400px;
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    align-items: start;
}

/* Glassmorphism Cards */
.card,
.side-card,
.chart-card,
.settings-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    /* Light catch */
    border-radius: 1.5rem;
    box-shadow: var(--glass-shadow);
    color: white;
}

.card {
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
}

.card:nth-child(1) {
    animation-delay: 0.1s;
}

.card:nth-child(2) {
    animation-delay: 0.2s;
}

.card:nth-child(3) {
    animation-delay: 0.3s;
}

.card:hover {
    transform: translateY(-12px);
    border-color: rgba(255, 255, 255, 0.25);
}

.card.temp:hover {
    box-shadow: 0 20px 40px -10px rgba(255, 42, 95, 0.3);
}

.card.hum:hover {
    box-shadow: 0 20px 40px -10px rgba(0, 240, 255, 0.3);
}

.card.sol:hover {
    box-shadow: 0 20px 40px -10px rgba(255, 215, 0, 0.3);
}

/* Ligne supérieure colorée */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    transition: height 0.4s ease;
}

.card:hover::before {
    height: 6px;
}

.card.temp::before {
    background-color: var(--temp-color);
    box-shadow: 0 0 20px var(--temp-color);
}

.card.hum::before {
    background-color: var(--hum-color);
    box-shadow: 0 0 20px var(--hum-color);
}

.card.sol::before {
    background-color: var(--sol-color);
    box-shadow: 0 0 20px var(--sol-color);
}

/* Glows subtils en fond de carte */
.card::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    filter: blur(60px);
    z-index: -1;
    opacity: 0.15;
    transition: opacity 0.4s ease;
}

.card.temp::after {
    background: var(--temp-color);
    top: -20px;
    right: -20px;
}

.card.hum::after {
    background: var(--hum-color);
    bottom: -20px;
    left: -20px;
}

.card.sol::after {
    background: var(--sol-color);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.card:hover::after {
    opacity: 0.3;
}

.icon {
    font-size: 2.5rem;
    margin-bottom: 0.8rem;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
    animation: float 6s ease-in-out infinite;
}

.card:nth-child(2) .icon {
    animation-delay: 1s;
}

.card:nth-child(3) .icon {
    animation-delay: 2s;
}

.title {
    font-size: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.value-wrapper {
    display: flex;
    align-items: baseline;
    gap: 0.4rem;
}

.value {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.05em;
}

.unit {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 600;
}

.temp .value {
    color: var(--temp-color);
    text-shadow: 0 0 30px rgba(255, 42, 95, 0.4);
}

.hum .value {
    color: var(--hum-color);
    text-shadow: 0 0 30px rgba(0, 240, 255, 0.4);
}

.sol .value {
    color: var(--sol-color);
    text-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.status {
    margin-top: 2.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.6rem 1.2rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--sys-color);
    box-shadow: 0 0 12px var(--sys-color);
    animation: pulseGlow 2s infinite;
}

/* Sidebar */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) backwards;
    animation-delay: 0.4s;
}

.side-card {
    padding: 1.5rem;
}

.side-title {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1.2rem;
}

.sys-info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 0.8rem;
}

.sys-info-item:last-child {
    margin-bottom: 0;
}

.sys-info-val {
    color: var(--text-main);
    font-weight: 600;
}

.sys-ok {
    color: var(--sys-color);
    text-shadow: 0 0 10px rgba(0, 255, 136, 0.3);
}

.sys-warn {
    color: var(--warn-color);
}

.sys-err {
    color: var(--alert-color);
}

/* Toggle Switches modernisés */
.actuator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.actuator-item:last-child {
    margin-bottom: 0;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: .4s;
    border-radius: 30px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    transition: .4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input:checked+.slider {
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

input:checked+.slider.fan:before {
    background-color: #00F0FF;
    box-shadow: 0 0 10px #00F0FF;
}

input:checked+.slider.pump:before {
    background-color: #0088FF;
    box-shadow: 0 0 10px #0088FF;
}

input:checked+.slider.light:before {
    background-color: #FFD700;
    box-shadow: 0 0 10px #FFD700;
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 5px;
}

.alert-list::-webkit-scrollbar {
    width: 5px;
}

.alert-list::-webkit-scrollbar-track {
    background: transparent;
}

.alert-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 5px;
}

.alert-item {
    font-size: 0.9rem;
    padding: 1rem;
    border-radius: 0.8rem;
    background: rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--text-muted);
    line-height: 1.4;
    color: #E2E8F0;
}

.alert-item.critical {
    border-left-color: var(--alert-color);
    background: linear-gradient(90deg, rgba(255, 0, 60, 0.1) 0%, transparent 100%);
}

.alert-item.warning {
    border-left-color: var(--warn-color);
}

.alert-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
    display: block;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.updated-time {
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    background: var(--card-bg);
    padding: 0.8rem 2rem;
    border-radius: 2rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ======================================= */
/* GRAPH STYLES (arduino_graphs.html)      */
/* ======================================= */

.page-content {
    width: 100%;
    max-width: 1300px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    animation: fadeInUp 0.8s ease-out backwards;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    padding: 1.5rem 2rem;
    border-radius: 1.5rem;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(20px);
    box-shadow: var(--glass-shadow);
}

.stats-container {
    display: flex;
    gap: 3rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
}

.actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-export {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 0.8rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(142, 45, 226, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-export:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(142, 45, 226, 0.6);
}

.charts-container {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.chart-card {
    padding: 2rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--glass-border);
}

.chart-title {
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    letter-spacing: 0.02em;
}

.title-temp {
    color: var(--temp-color);
    text-shadow: 0 0 10px rgba(255, 42, 95, 0.3);
}

.title-hum {
    color: var(--hum-color);
    text-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.title-sol {
    color: var(--sol-color);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.chart-current-value {
    font-size: 1.8rem;
    font-weight: 800;
}

.canvas-container {
    position: relative;
    height: 350px;
    width: 100%;
}

.chart-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
    border-radius: 1.5rem 0 0 1.5rem;
}

#card-temp::before {
    background-color: var(--temp-color);
    box-shadow: 0 0 15px var(--temp-color);
}

#card-hum::before {
    background-color: var(--hum-color);
    box-shadow: 0 0 15px var(--hum-color);
}

#card-sol::before {
    background-color: var(--sol-color);
    box-shadow: 0 0 15px var(--sol-color);
}

.controls {
    display: flex;
    gap: 0.6rem;
}

.btn-time {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-time:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-time.active {
    background: white;
    color: black;
    border-color: white;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
}

/* ======================================= */
/* SETTINGS STYLES (arduino_settings.html) */
/* ======================================= */

.settings-container {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
    animation: fadeInUp 0.8s ease-out backwards;
}

.settings-card {
    padding: 3rem;
}

.card-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 2.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.8rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
    letter-spacing: 0.02em;
}

input[type="text"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 1rem 1.2rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.8rem;
    color: white;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    outline: none;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:focus {
    border-color: var(--primary-hover);
    background: rgba(0, 0, 0, 0.5);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(142, 45, 226, 0.2);
}

.helper-text {
    display: block;
    font-size: 0.85rem;
    color: rgba(148, 163, 184, 0.7);
    margin-top: 0.5rem;
    font-weight: 400;
}

.btn-save {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 1.2rem 2rem;
    border-radius: 1rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    cursor: pointer;
    width: 100%;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    margin-top: 1.5rem;
    box-shadow: 0 8px 20px rgba(142, 45, 226, 0.4);
}

.btn-save:hover {
    transform: translateY(-4px);
    box-shadow: 0 15px 30px rgba(142, 45, 226, 0.6);
    filter: brightness(1.1);
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--success-color);
    color: #000;
    padding: 1.2rem 2.5rem;
    border-radius: 1rem;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 10px 25px rgba(0, 230, 118, 0.4);
    transform: translateY(150px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* MEDIA QUERIES */
@media (max-width: 1024px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .toolbar {
        flex-direction: column;
        gap: 1.5rem;
        align-items: flex-start;
    }

    .stats-container {
        gap: 1.5rem;
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 768px) {
    .dashboard {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2.2rem;
    }

    .card {
        padding: 2rem 1.5rem;
    }

    .icon {
        font-size: 3rem;
    }

    .value {
        font-size: 3.5rem;
    }

    .canvas-container {
        height: 250px;
    }

    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .controls {
        align-self: flex-start;
        flex-wrap: wrap;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .settings-card {
        padding: 2rem 1.5rem;
    }

    .navigation {
        flex-direction: column;
        border-radius: 1.5rem;
    }

    #device-selector {
        margin-bottom: 0.5rem;
        margin-right: 0;
        width: 100%;
    }
}