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

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0d1117;
    color: #e6edf3;
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background-color: #161b22;
    border-right: 1px solid #30363d;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid #30363d;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
}

.sidebar-header p {
    font-size: 12px;
    color: #8b949e;
    margin-top: 4px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 0;
    overflow-y: auto;
}

.sidebar-nav a,
.sidebar-nav .nav-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #8b949e;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    cursor: pointer;
    background: none;
    border-top: none;
    border-right: none;
    border-bottom: none;
    width: 100%;
    text-align: left;
}

.sidebar-nav a:hover,
.sidebar-nav .nav-toggle:hover {
    color: #ffffff;
    background-color: #1c2128;
}

.sidebar-nav a.active {
    color: #ffffff;
    background-color: #1c2128;
    border-left-color: #58a6ff;
}

.sidebar-nav a .icon,
.sidebar-nav .nav-toggle .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav .arrow {
    margin-left: auto;
    font-size: 10px;
    transition: transform 0.2s;
}

.sidebar-nav .arrow.open {
    transform: rotate(90deg);
}

.nav-subs {
    display: none;
}

.nav-subs.open {
    display: block;
}

.nav-subs a {
    padding-left: 52px;
    font-size: 13px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #8b949e;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    color: #ffffff;
    background-color: #1c2128;
}

.sidebar-nav a.active {
    color: #ffffff;
    background-color: #1c2128;
    border-left-color: #58a6ff;
}

.sidebar-nav a .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #30363d;
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.sidebar-footer .user-info .user-details {
    flex: 1;
    min-width: 0;
}

.sidebar-footer .settings-btn {
    color: #8b949e;
    text-decoration: none;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.sidebar-footer .settings-btn.active-settings {
    color: #58a6ff;
}

.sidebar-footer .settings-btn:hover {
    color: #ffffff;
    background-color: #1c2128;
}

.sidebar-footer .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #30363d;
    object-fit: cover;
}

.sidebar-footer .user-name {
    font-size: 14px;
    color: #e6edf3;
}

.sidebar-footer .user-email {
    font-size: 12px;
    color: #8b949e;
}

/* ===== Hamburger toggle ===== */
.hamburger {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #e6edf3;
    font-size: 22px;
    padding: 8px 12px;
    cursor: pointer;
    line-height: 1;
}

.hamburger:hover {
    background: #1c2128;
}

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
}

/* ===== Main content ===== */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 32px 40px;
    min-height: 100vh;
}

.main-content h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.main-content p {
    color: #8b949e;
    line-height: 1.6;
    margin-bottom: 16px;
}

/* ===== Cards ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 24px;
    transition: border-color 0.2s;
}

.card:hover {
    border-color: #58a6ff;
}

.card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #ffffff;
}

.card p {
    font-size: 13px;
    margin-bottom: 0;
}


/* ===== Landing page (plein ecran) ===== */
body.landing-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #0d1117;
}

.landing {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 24px;
    text-align: center;
    max-width: 90vw;
}

.landing-logo {
    max-width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    margin-bottom: 32px;
    border-radius: 8px;
}

.landing-subtitle {
    color: #8b949e;
    font-size: 16px;
    margin-bottom: 32px;
}

/* ===== Login page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    margin: 0;
    padding: 20px;
}

.login-card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 48px 40px;
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    font-size: 24px;
    margin-bottom: 8px;
}

.login-card p {
    color: #8b949e;
    margin-bottom: 32px;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background-color: #ffffff;
    color: #1f1f1f;
    border: none;
    border-radius: 8px;
    padding: 12px 28px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow 0.2s;
}

.google-btn:hover {
    box-shadow: 0 2px 12px rgba(88, 166, 255, 0.3);
}

.google-btn img {
    width: 20px;
    height: 20px;
}

/* ===== Profile section ===== */
.profile-section {
    display: flex;
    align-items: center;
    gap: 20px;
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 24px;
}

.profile-section img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid #30363d;
}

.profile-section .info h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.profile-section .info p {
    font-size: 14px;
    margin-bottom: 0;
}

.btn {
    display: inline-block;
    background-color: #21262d;
    color: #e6edf3;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 8px 20px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: #30363d;
}

.btn-danger {
    color: #f85149;
    border-color: #f85149;
}

.btn-danger:hover {
    background-color: rgba(248, 81, 73, 0.1);
}

.btn-xs {
    padding: 3px 10px;
    font-size: 11px;
    line-height: 1.4;
}

.cb-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
    padding: 0 8px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hamburger {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
    }

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

    .overlay.show {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 24px 20px;
        padding-top: 64px;
    }

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

    .login-card {
        padding: 32px 20px;
    }

    .profile-section {
        flex-direction: column;
        text-align: center;
    }
}

/* ===== Devices table ===== */
.devices-table {
    margin-top: 20px;
    border: 1px solid #30363d;
    border-radius: 8px;
    overflow: hidden;
}

.devices-header {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 1.5fr 1fr;
    gap: 12px;
    padding: 12px 20px;
    background-color: #1c2128;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
    border-bottom: 1px solid #30363d;
}

.device-row {
    display: grid;
    grid-template-columns: 2fr 1.5fr 1.5fr 1.5fr 1fr;
    gap: 12px;
    padding: 14px 20px;
    font-size: 14px;
    align-items: center;
    border-bottom: 1px solid #21262d;
    transition: background-color 0.2s;
}

.device-row:last-child {
    border-bottom: none;
}

.device-row:hover {
    background-color: #1c2128;
}

.device-name {
    color: #58a6ff;
    font-weight: 500;
}

.status {
    font-size: 13px;
}

.status.up {
    color: #3fb950;
}

.status.down {
    color: #f85149;
}

/* ===== Under Development ===== */
.under-dev {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 80px 20px;
    min-height: 60vh;
}

.under-dev-icon {
    font-size: 64px;
    margin-bottom: 16px;
    color: #d29922;
}

.under-dev h1 {
    font-size: 28px;
    margin-bottom: 12px;
}

.under-dev p {
    color: #8b949e;
    max-width: 480px;
}

/* ===== Build Terminal ===== */
.build-terminal
{
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin-top: 16px;
    overflow: hidden;
}

.build-terminal-header
{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    font-size: 13px;
    font-weight: 600;
    color: #e6edf3;
}

.build-terminal-actions
{
    display: flex;
    gap: 8px;
    align-items: center;
}

.build-terminal-output
{
    height: 400px;
    overflow-y: auto;
    padding: 16px;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: #e6edf3;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: #0d1117;
}

.build-terminal-output::-webkit-scrollbar
{
    width: 8px;
}

.build-terminal-output::-webkit-scrollbar-track
{
    background: #0d1117;
}

.build-terminal-output::-webkit-scrollbar-thumb
{
    background: #30363d;
    border-radius: 4px;
}

/* ===== Responsive devices ===== */
@media (max-width: 768px) {
    .devices-header,
    .device-row {
        grid-template-columns: 1.5fr 1fr 1fr;
    }

    .devices-header span:nth-child(4),
    .devices-header span:nth-child(5),
    .device-row span:nth-child(4),
    .device-row span:nth-child(5) {
        display: none;
    }
}

/* ===== Sub-sub navigation ===== */
.nav-sub-sub {
    padding-left: 72px !important;
    font-size: 12px !important;
    color: #8b949e;
}

.nav-sub-sub:hover {
    color: #ffffff;
}

/* ===== ESP32 Installation ===== */
.esp-panel {
    margin-top: 16px;
}

.esp-card {
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 24px;
}

.esp-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
    color: #ffffff;
}

.esp-card p {
    font-size: 13px;
    color: #8b949e;
    margin-bottom: 0;
}

/* Browser alert */
.esp-browser-alert {
    display: none;
    background-color: #161b22;
    border: 1px solid #d29922;
    border-radius: 8px;
    padding: 32px;
    text-align: center;
    max-width: 520px;
    margin: 40px auto;
}

.esp-alert-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.esp-browser-alert h2 {
    font-size: 20px;
    margin-bottom: 12px;
    color: #d29922;
}

.esp-browser-alert p {
    color: #8b949e;
    font-size: 14px;
}

.browser-list {
    list-style: none;
    padding: 0;
    margin: 16px 0;
    text-align: left;
    display: inline-block;
}

.browser-list li {
    padding: 6px 0;
    font-size: 14px;
    color: #e6edf3;
}

.browser-icon {
    color: #58a6ff;
    margin-right: 8px;
}

/* Info grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.info-item {
    background-color: #0d1117;
    border: 1px solid #21262d;
    border-radius: 6px;
    padding: 12px 16px;
}

.info-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: #8b949e;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.info-value {
    display: block;
    font-size: 15px;
    color: #ffffff;
    font-weight: 500;
}

/* Console log */
.esp-log {
    width: 100%;
    height: 180px;
    background-color: #0d1117;
    border: 1px solid #21262d;
    border-radius: 6px;
    color: #e6edf3;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    padding: 12px;
    resize: vertical;
    margin-top: 8px;
}

/* ===== Stepper ===== */
.stepper {
    display: flex;
    gap: 4px;
    margin: 20px 0 32px;
    justify-content: center;
}

.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 20px;
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    font-size: 13px;
    color: #8b949e;
    opacity: 0.5;
}

.step.active {
    opacity: 1;
    border-color: #58a6ff;
    color: #e6edf3;
}

.step.done {
    opacity: 1;
    border-color: #3fb950;
    color: #3fb950;
}

.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #30363d;
    font-size: 12px;
    font-weight: 600;
}

.step.active .step-num {
    background-color: #58a6ff;
    color: #ffffff;
}

.step.done .step-num {
    background-color: #3fb950;
    color: #ffffff;
}

/* ===== Modals ===== */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
}

.modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    padding: 40px;
    max-width: 520px;
    width: 90%;
    z-index: 2001;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-content {
    text-align: center;
}

.modal-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.modal h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: #ffffff;
}

.modal p {
    color: #8b949e;
    font-size: 14px;
    margin-bottom: 16px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Alert box */
.alert-box {
    background-color: #1c2128;
    border: 1px solid #d29922;
    border-radius: 8px;
    padding: 20px;
    text-align: left;
    margin: 12px 0;
}

.alert-box strong {
    display: block;
    color: #d29922;
    font-size: 14px;
    margin-bottom: 8px;
}

.alert-box p {
    font-size: 13px;
    margin-bottom: 4px;
}

.alert-error {
    border-color: #f85149;
}

.alert-error strong {
    color: #f85149;
}

/* Connect status */
.connect-status {
    font-size: 14px;
    padding: 10px;
    border-radius: 6px;
    background-color: #0d1117;
    border: 1px solid #30363d;
    margin: 12px 0;
}

.connect-status.ok {
    color: #3fb950;
    border-color: #3fb950;
}

.connect-status.error {
    color: #f85149;
    border-color: #f85149;
}

/* Spinner */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #30363d;
    border-top-color: #58a6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 16px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Flash partition bar */
.flash-bar-seg {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    color: #ffffff;
    position: relative;
    transition: flex 0.3s;
    min-width: 0;
    overflow: hidden;
    border-right: 1px solid #0d1117;
}
.flash-bar-seg:last-child { border-right: none; }
.flash-bar-seg.empty {
    background: #1c2128;
    color: #484f58;
}
.flash-bar-seg.bootloader {
    background: #d29922;
}
.flash-bar-seg.part-table {
    background: #f0883e;
}
.flash-bar-seg.app {
    background: #58a6ff;
}
.flash-bar-seg.data-nvs {
    background: #3fb950;
}
.flash-bar-seg.data-otadata {
    background: #a371f7;
}
.flash-bar-seg.data-phy {
    background: #db6d28;
}
.flash-bar-seg.data-spiffs {
    background: #f78166;
}
.flash-bar-seg.data-fat {
    background: #bc8cff;
}
.flash-bar-seg.unknown {
    background: #30363d;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #e6edf3;
}
.legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}
