/* Universal Updater - Projects Manager - Stylesheet - Dark Theme */

:root {
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --secondary: #9ca3af;
    --success: #34d399;
    --danger: #f87171;
    --warning: #fbbf24;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.3);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.nav-brand a {
    color: inherit;
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user span {
    color: var(--text-secondary);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 600;
}

.back-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.back-link:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    background: var(--bg-hover);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.auth-card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
}

.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-card h2 {
    text-align: center;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.auth-link {
    text-align: center;
    margin-top: 1rem;
    color: var(--text-secondary);
}

.auth-link a {
    color: var(--primary);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.2s;
    background: var(--bg);
    color: var(--text);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.alert-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.3);
}

.alert-success {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
    border: 1px solid rgba(52, 211, 153, 0.3);
}

/* Device Grid */
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

/* Device Card */
.device-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    transition: box-shadow 0.2s;
}

.device-card:hover {
    box-shadow: var(--shadow-lg);
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.device-info {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.device-icon {
    font-size: 2rem;
}

.device-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.device-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.device-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    font-weight: 500;
}

.device-status.online {
    background: #ecfdf5;
    color: var(--success);
}

.device-status.offline {
    background: #f3f4f6;
    color: var(--secondary);
}

.device-controls {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg);
    border-radius: var(--radius);
}

.device-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* Projects */
.projects-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-subtitle {
    color: var(--text-secondary);
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.project-card-link {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1rem;
    color: inherit;
    text-decoration: none;
}

.project-card-link:hover {
    background: rgba(30, 41, 59, 0.75);
}

.project-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.project-card h2 {
    font-size: 1.1rem;
}

.project-description {
    color: var(--text-secondary);
    margin-top: 0.35rem;
    font-size: 0.9rem;
}

.project-version-pill {
    display: inline-flex;
    align-items: center;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
}

.project-stats {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.project-detail-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.project-detail-card h2 {
    font-size: 1rem;
}

.danger-zone {
    border-color: rgba(248, 113, 113, 0.35);
}

.project-edit-form {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.project-edit-form label {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.project-edit-form input {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 0.45rem 0.6rem;
}

.project-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.version-list {
    border-top: 1px solid var(--border);
    margin-top: 0.2rem;
    padding-top: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.version-row {
    display: flex;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.65);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.version-row-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.6rem;
}

.version-row-info {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.version-badge {
    color: var(--text);
    font-size: 0.9rem;
}

.version-name {
    background: var(--bg-hover);
    color: var(--primary-hover);
    border-radius: 4px;
    padding: 0.1rem 0.45rem;
    font-size: 0.78rem;
    font-weight: 500;
}

.version-meta {
    color: var(--text-secondary);
}

.version-files-toggle {
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    cursor: pointer;
}

.version-file-list {
    border-top: 1px solid var(--border);
    padding: 0.4rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    max-height: 260px;
    overflow-y: auto;
}

.version-file-list[hidden] {
    display: none !important;
}

.version-file-entry {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-size: 0.78rem;
    padding: 0.1rem 0;
    border-bottom: 1px solid rgba(51,65,85,0.4);
}

.version-file-entry:last-child {
    border-bottom: none;
}

.version-file-name {
    color: var(--text);
    word-break: break-all;
}

.version-file-size {
    color: var(--text-secondary);
    white-space: nowrap;
    flex-shrink: 0;
}

.projects-empty-state {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
}

.projects-empty-state h2 {
    margin-bottom: 0.5rem;
}

.projects-empty-state p {
    color: var(--text-secondary);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.modal-card {
    width: min(620px, 100%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.project-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-progress-panel {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(15, 23, 42, 0.65);
    padding: 0.75rem;
}

.upload-progress-panel h4 {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.upload-progress-files {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 220px;
    overflow: auto;
}

.upload-file-row {
    display: grid;
    grid-template-columns: 1fr 140px 44px;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.78rem;
}

.upload-file-row .file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-secondary);
}

.upload-file-row progress,
.manifest-progress progress {
    width: 100%;
    height: 10px;
}

.manifest-progress {
    margin-top: 0.65rem;
}

.manifest-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

/* Power Button */
.power-control {
    margin-bottom: 1rem;
}

.power-btn {
    width: 100%;
    padding: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    border: 2px solid;
    transition: all 0.2s;
}

.power-btn.on {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.power-btn.off {
    background: var(--bg);
    border-color: var(--border);
    color: var(--text-secondary);
}

.power-btn:hover {
    transform: scale(1.02);
}

.power-icon {
    margin-right: 0.5rem;
}

/* Range Controls */
.range-control {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.range-control input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    appearance: none;
    cursor: pointer;
}

.range-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

.range-value {
    min-width: 60px;
    text-align: right;
    font-weight: 500;
    color: var(--text);
}

.temperature-control label,
.brightness-control label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.temp-value,
.brightness-value {
    color: var(--primary);
    font-weight: 600;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    margin: 2rem;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-close:hover {
    color: var(--text);
}

.modal-content form {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    grid-column: 1 / -1;
}

/* Device Detail Page */
.device-detail {
    display: grid;
    gap: 1.5rem;
    /* grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); */
}

.detail-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.detail-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.detail-header h2 {
    margin-bottom: 0;
}

.detail-list {
    display: grid;
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-item dt {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.detail-item dd {
    font-weight: 500;
    text-transform: capitalize;
}

.control-panel {
    display: grid;
    gap: 1.5rem;
}

.control-section h3 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text-secondary);
}

/* HTMX loading indicator */
.htmx-request {
    opacity: 0.7;
    pointer-events: none;
}

.htmx-request::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem;
    }

    .container {
        padding: 1rem;
    }

    .page-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .device-grid {
        grid-template-columns: 1fr;
    }

    .device-detail {
        grid-template-columns: 1fr;
    }

    .sensors-grid {
        grid-template-columns: 1fr;
    }
}

/* Thermostat Sensor Styles */
.sensors-section {
    margin-top: 1.5rem;
}

.sensors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.sensor-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.sensor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.sensor-icon {
    font-size: 1.25rem;
}

.sensor-id {
    font-weight: 600;
    flex: 1;
}

.heater-indicator {
    font-size: 1rem;
}

.heater-indicator.on {
    color: var(--danger);
}

.heater-indicator.off {
    color: var(--secondary);
}

.sensor-readings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.reading {
    display: flex;
    flex-direction: column;
}

.reading-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.reading-value {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.reading-value.low {
    color: var(--warning);
}

.sensor-footer {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.last-updated {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.no-sensors {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.no-sensors .hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.thermostat-status {
    margin-bottom: 1rem;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-badge.online {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.offline {
    background: rgba(107, 114, 128, 0.1);
    color: var(--secondary);
}

.thermostat-target {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.target-label {
    font-size: 0.875rem;
    opacity: 0.9;
}

.target-value {
    font-size: 1.5rem;
    font-weight: 700;
}

.reading-value.target {
    color: var(--primary);
}

/* Temperature Control Slider */
.temperature-control {
    margin-top: 0.5rem;
}

.temperature-control label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.temperature-control .range-control {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.temperature-control .range-min,
.temperature-control .range-max {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.temperature-control input[type="range"] {
    flex: 1;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #3b82f6, #ef4444);
    appearance: none;
    cursor: pointer;
}

.temperature-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.temperature-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.temperature-control input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.temperature-control .temp-display {
    text-align: center;
    margin-top: 0.75rem;
}

.temperature-control .temp-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.temp-control {
    padding: 0.5rem 0;
}

/* Heater Status Control */
.heater-status-control {
    margin-bottom: 1rem;
}

.heater-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-weight: 600;
    transition: all 0.3s ease;
}

.heater-indicator.heating {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    animation: pulse-heating 2s ease-in-out infinite;
}

.heater-indicator.idle {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
}

.heater-indicator.unknown {
    background: var(--bg);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.heater-icon {
    font-size: 1.25rem;
}

.heater-text {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

@keyframes pulse-heating {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(238, 90, 36, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(238, 90, 36, 0);
    }
}

/* Card Sensors Display */
.card-sensors {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-bottom: 1rem;
}

.card-sensor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.card-sensor-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.card-sensor-item:first-child {
    padding-top: 0;
}

.sensor-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.sensor-temp {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.sensor-humidity {
    font-size: 0.875rem;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}

/* Delete Sensor Button */
.btn-delete-sensor {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    opacity: 0.5;
    transition: opacity 0.2s, transform 0.2s;
    margin-left: auto;
}

.btn-delete-sensor:hover {
    opacity: 1;
    transform: scale(1.1);
}

.sensor-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Graphs Section */
.graphs-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.graphs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.graphs-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.graph-controls select {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
}

.graph-controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.reset-zoom-btn {
    padding: 0.35rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
}

.reset-zoom-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.graph-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-style: italic;
}

.reset-graph-btn {
    font-size: 0.6rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    margin-left: 0.4rem;
    transition: all 0.2s;
}

.reset-graph-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

.graphs-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.graph-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.graph-card-wide {
    grid-column: 1 / -1;
}

.graph-card-wide .graph-svg {
    min-height: 220px;
}

.graph-card h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.graph-svg {
    width: 100%;
    min-height: 160px;
}

.graph-svg svg {
    width: 100%;
    height: auto;
}

.axis text {
    font-size: 9px;
    fill: var(--text-secondary);
}

.axis path,
.axis line {
    stroke: var(--border);
}

.graph-line {
    fill: none;
    stroke-width: 1.5;
}

.target-line {
    stroke-dasharray: 4, 2;
}

.no-graph-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.graph-tooltip {
    position: absolute;
    padding: 0.4rem 0.6rem;
    background: var(--bg-card);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.7rem;
    pointer-events: none;
    z-index: 1000;
    line-height: 1.3;
    box-shadow: var(--shadow-lg);
}

.legend text {
    fill: var(--text-secondary);
}

/* History Stats */
.history-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.stat-icon {
    font-size: 1.1rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
}

@media (max-width: 768px) {
    .history-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .graphs-container {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .graphs-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .graph-card {
        padding: 0.5rem;
    }
    
    .graph-svg {
        min-height: 140px;
    }
    
    .graph-card-wide .graph-svg {
        min-height: 180px;
    }
}

/* ==========================================
   Thermostat Controls Section
   ========================================== */

.thermostat-controls-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.thermostat-controls-section h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: 600;
}

.thermostat-control-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 1rem;
}

/* Vertical Temperature Slider Container */
.temp-slider-vertical-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.temp-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.temp-btn {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.temp-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.temp-btn:active {
    transform: scale(0.95);
}

.temp-btn-up {
    color: var(--danger);
}

.temp-btn-down {
    color: var(--primary);
}

/* Vertical Slider Wrapper */
.temp-slider-vertical-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    height: 180px;
    position: relative;
}

.temp-label-max,
.temp-label-min {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Vertical Slider Styling - using writing-mode for proper vertical behavior */
.temp-slider-vertical {
    -webkit-appearance: none;
    appearance: none;
    width: 8px;
    height: 140px;
    background: linear-gradient(to top, var(--primary), var(--danger));
    border-radius: 4px;
    outline: none;
    writing-mode: vertical-lr;
    direction: rtl;
}

.temp-slider-vertical::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: all 0.15s;
}

.temp-slider-vertical::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    border-color: var(--primary-hover);
}

.temp-slider-vertical::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: 3px solid var(--primary);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* Large Temperature Display */
.temp-display-large {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 0.25rem;
    background: var(--bg);
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    min-width: 100px;
}

.temp-value-big {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    min-width: 60px;
    text-align: right;
}

.temp-unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Heater Status Display in Controls */
.heater-status-display {
    flex-shrink: 0;
}

/* Manual Mode Toggle */
.manual-mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.toggle-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg);
    border: 2px solid var(--border);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-input:checked + .toggle-slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

.toggle-input:checked + .toggle-slider:before {
    transform: translateX(22px);
    background-color: white;
}

.toggle-input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-hint {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Card-specific compact controls */
.device-card .thermostat-controls-section {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.device-card .thermostat-controls-section h3 {
    display: none;
}

.device-card .thermostat-control-panel {
    gap: 1rem;
    padding: 0.5rem;
    justify-content: center;
}

.device-card .temp-slider-vertical-container {
    gap: 1rem;
}

.device-card .temp-slider-vertical-wrapper {
    height: 120px;
}

.device-card .temp-slider-vertical {
    height: 80px;
}

.device-card .temp-value-big {
    font-size: 1.5rem;
    min-width: 45px;
}

.device-card .temp-display-large {
    padding: 0.5rem 0.75rem;
    min-width: 80px;
}

.device-card .temp-btn {
    width: 32px;
    height: 32px;
    font-size: 1.25rem;
}

.device-card .temp-buttons {
    gap: 0.5rem;
}

.device-card .heater-status-display {
    display: none;
}

.device-card .manual-mode-toggle {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .thermostat-control-panel {
        flex-direction: column;
        align-items: center;
        gap: 1.5rem;
    }
    
    .temp-slider-vertical-container {
        flex-direction: row;
    }
    
    .temp-buttons {
        flex-direction: column;
    }
}
