/* Westfalia Connect - Cloudflare Frontend - Base & Login */
:root[data-theme="light"] {
    --bg-color: #f5f5f7;
    --text-color: #1d1d1f;
    --tile-bg: #ffffff;
    --tile-border: #e5e5e5;
    --tile-shadow: rgba(0, 0, 0, 0.05);
    --secondary-text: #86868b;
    --accent-color: rgb(117, 161, 255);
    --status-active: #28a745;
    --status-danger: #dc3545;
    --toggle-bg: #e5e5e7;
    --toggle-bg-active: var(--accent-color);
    --toggle-slider-bg: #ffffff;
    --toggle-slider-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

:root[data-theme="dark"] {
    --bg-color: #1d1d1f;
    --text-color: #f5f5f7;
    --tile-bg: #2d2d2f;
    --tile-border: #3d3d3f;
    --tile-shadow: rgba(0, 0, 0, 0.2);
    --secondary-text: #a1a1a6;
    --accent-color: rgb(117, 161, 255);
    --status-active: #28a745;
    --status-danger: #dc3545;
    --toggle-bg: #3a3a3c;
    --toggle-bg-active: var(--accent-color);
    --toggle-slider-bg: #ffffff;
    --toggle-slider-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
}

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

html { overflow-x: hidden; width: 100%; }

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: "Noto Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 400;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    width: 100%;
    min-height: 100vh;
}

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

.login-panel {
    background: var(--tile-bg);
    border-radius: 16px;
    padding: 40px;
    max-width: 440px;
    width: 100%;
    box-shadow: 0 8px 24px var(--tile-shadow);
    border: 1px solid var(--tile-border);
}

.login-panel h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-color);
}

.login-panel .subtitle {
    color: var(--secondary-text);
    font-size: 14px;
    margin-bottom: 28px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--tile-border);
    border-radius: 10px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 15px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.form-group .hint {
    font-size: 12px;
    color: var(--secondary-text);
    margin-top: 6px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.btn-primary:hover { opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.login-status {
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    text-align: center;
    font-size: 14px;
}

.login-status.error {
    background: rgba(220, 53, 69, 0.15);
    color: var(--status-danger);
}

.login-status.success {
    background: rgba(40, 167, 69, 0.15);
    color: var(--status-active);
}

.login-status.loading {
    color: var(--secondary-text);
}

.form-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-top: 12px;
    font-size: 13px;
}

.form-row a {
    color: var(--accent-color);
    text-decoration: none;
}

.form-row a:hover {
    text-decoration: underline;
}

.login-status .debug-link {
    margin-top: 8px;
    font-size: 12px;
    word-break: break-all;
}

.login-status .debug-link a {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Taskbar (local-style): connection left, temps/menu right */
.taskbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--tile-bg);
    border-bottom: 1px solid var(--tile-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10000;
    box-shadow: 0 1px 3px var(--tile-shadow);
}

.taskbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.taskbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.taskbar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-color);
    font-size: 14px;
}

.taskbar-item.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.connection-label { font-weight: 600; }

.status-led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-danger);
    border: 1px solid var(--tile-border);
    box-shadow: 0 0 6px rgba(220, 53, 69, 0.4);
}

.status-led.connected {
    background: var(--status-active);
    box-shadow: 0 0 6px rgba(40, 167, 69, 0.5);
}

.status-led.disconnected { background: var(--status-danger); }

.temp-display { font-weight: 500; color: var(--text-color); }
.temp-separator {
    width: 1px;
    height: 14px;
    background: var(--tile-border);
    margin: 0 8px;
}

/* Burger menu button (local-style) */
.menu-button {
    position: fixed;
    top: 68px;
    right: 20px;
    width: 44px;
    height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    z-index: 10001;
    transition: all 0.2s ease;
    background: var(--tile-bg);
    border: 1px solid var(--tile-border);
    border-radius: 12px;
    box-shadow: 0 4px 6px var(--tile-shadow);
    -webkit-tap-highlight-color: transparent;
}

.menu-line {
    width: 20px;
    height: 2px;
    background-color: var(--text-color);
    border-radius: 2px;
}

.dropdown-menu {
    position: fixed;
    top: 118px;
    right: 20px;
    background-color: var(--tile-bg);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--tile-shadow);
    border: 1px solid var(--tile-border);
    padding: 8px 0;
    min-width: 200px;
    z-index: 10002;
    display: none;
    font-family: "Noto Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    backdrop-filter: blur(10px);
}

.dropdown-menu.show {
    display: block;
    animation: navFadeIn 0.2s ease;
}

@keyframes navFadeIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-item {
    padding: 12px 20px;
    color: var(--text-color);
    font-size: 16px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.menu-item:hover { background-color: var(--bg-color); }

/* Theme toggle in menu */
.theme-menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    color: var(--text-color);
    font-size: 16px;
    border-top: 1px solid var(--tile-border);
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

.theme-menu-item #themeToggleLabel { font-weight: 500; flex: 1; }

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
    margin-left: 15px;
    flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--toggle-bg);
    transition: 0.2s ease;
    border-radius: 31px;
    border: none;
    box-shadow: none;
}

.toggle-switch .toggle-slider:before {
    position: absolute;
    content: "";
    height: 27px; width: 27px;
    left: 2px; bottom: 2px;
    background-color: var(--toggle-slider-bg);
    transition: 0.2s ease;
    border-radius: 50%;
    box-shadow: var(--toggle-slider-shadow);
}

.toggle-switch input:checked ~ .toggle-slider {
    background-color: var(--toggle-bg-active);
}

.toggle-switch input:checked ~ .toggle-slider:before {
    transform: translateX(20px);
}

@media (max-width: 768px) {
    .taskbar { height: 50px; padding: 0 15px; }
    .menu-button { top: 63px; right: 15px; width: 40px; height: 40px; }
    .dropdown-menu { top: 108px; right: 15px; min-width: 180px; }
}
