:root {
    --primary-color: #2196F3;
    --success-color: #4CAF50;
    --danger-color: #f44336;
    --neutral-color: #3a3a3a;
    --background-color: #f7f7f7;
    --card-background: #ffffff;
    --text-color: #333333;
    --border-radius: 12px;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none !important;
}

.flex {
    display: flex;
    align-items: center;
    gap: 8px;
}

.justify-between {
    justify-content: space-between;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.rounded-md {
    border: none;
    border-radius: 10px;
}

.px-3 {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.shadow-sm {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.inline-flex {
    display: inline-flex;
}

.toggle {
    padding: 4px 8px;
    height: 2rem;
    vertical-align: middle;
    background: var(--card-background);
    border: none;
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background-color 0.3s ease;
    /* Smooth transition for color change */
}


.toggle.active {
    background: var(--danger-color);
    /* Red when active */
    color: white;
}

.toggle:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle.danger {
    background: var(--danger-color);
    color: white;
}



.chart-controls {
    align-items: center;
}

/* Add theme switch styles */

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary-color);
}

input:checked+.slider:before {
    transform: translateX(16px);
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
}

.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding: 20px;
}

.card {
    background: var(--card-background);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.card.card-wide {
    grid-column: 1 / span 2;
}

.card-header {
    /* font-size: 1.2em; */
    /* font-weight: 600; */
    margin-bottom: 10px;
    color: var(--text-color);
}

.gauge-container {
    text-align: center;
}

.gauge {
    max-width: 100%;
    height: auto;
}

.gauge-arc {
    transition: all 0.3s ease;
}

.temp-gauge .gauge-arc {
    stroke: var(--danger-color);
}

.humidity-gauge .gauge-arc {
    stroke: var(--primary-color);
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.history-table th,
.history-table td {
    padding: 10px;
    text-align: left;
    border: 1px solid #ddd;
}

.history-table th {
    background: #f4f4f4;
}

.threshold-container {
    margin-top: 1rem;
    padding: 0 1.5rem;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-sizing: border-box;
}

.threshold-container input[type="range"] {
    flex: 1;
}

#threshold-value {
    min-width: 2.5rem;
    text-align: right;
}

.sensor-rows {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem;
    width: 100%;
}

.sensor-row {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.sensor-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sensor-info {
    flex: 1;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sensor-value {
    margin-right: 1rem;
}

.moisture-bar-container {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin: 4px 0;
}

.threshold-control {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.threshold-slider {
    flex: 1;
}

.sensor-name {
    font-weight: 500;
}

.sensor-value {
    font-size: 0.875rem;
    color: var(--text-color);
}

.moisture-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.water-now-btn {
    width: 5rem;
    /* padding: 4px 8px;
    background: var(--card-background);
    border: none;
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer; */
}



.last-watered {
    font-size: 0.75rem;
    color: var(--text-color);
    opacity: 0.8;
}

/* Add this to your existing auto mode handling */
.threshold-control {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.threshold-control.hidden {
    opacity: 0;
    pointer-events: none;
}

.server-warning {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--neutral-color);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius);
    font-size: 1.2em;
    font-weight: bold;
    z-index: 1000;
    display: none;
}

/* Example CSS for responsive design */
@media (max-width: 600px) {
    .dashboard {
        grid-template-columns: 1fr;
        padding: 10px;
        /* Reduce padding on smaller screens */
    }

    .chart-controls {
        flex-direction: column;
        /* Stack buttons vertically */
        align-items: center;
        /* Center buttons */
    }

    .chart-button,
    .water-now-btn {
        width: 100%;
        padding: 12px;
        font-size: 16px;
    }


    .chart-button,
    .water-now-btn {
        padding: 12px;
        /* Increase padding for larger touch area */
        font-size: 16px;
        /* Increase font size for readability */
    }

}