/* ─── Global Reset & Theme Variables ────────────────────────────────────────── */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a, #111827, #022c22);
    --card-bg: rgba(30, 41, 59, 0.45);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary-green: #10b981;
    --accent-blue: #0ea5e9;
    --accent-red: #ef4444;
    --accent-glow: rgba(16, 185, 129, 0.25);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --font-family: 'Outfit', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-family);
}

body {
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ─── Login Screen Layout ────────────────────────────────────────────────────── */
.login-body {
    background: radial-gradient(circle at center, #1e293b, #0f172a, #022c22);
}

.login-card {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 45px 35px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.lock-icon-container {
    width: 65px;
    height: 65px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.lock-icon {
    font-size: 1.8rem;
}

.login-card h2 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #34d399, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.login-form input[type="password"] {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 12px 18px;
    color: white;
    font-size: 1rem;
    outline: none;
    text-align: center;
    transition: all 0.3s ease;
}

.login-form input[type="password"]:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 12px rgba(14, 165, 233, 0.25);
}

.login-error-msg {
    color: #f87171;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 10px;
    width: 100%;
}

.login-btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

/* ─── Dashboard Container ────────────────────────────────────────────────────── */
.dashboard-container {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* ─── Header Styling ─────────────────────────────────────────────────────────── */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    padding: 20px 30px;
    border-radius: 20px;
}

@media (max-width: 600px) {
    .main-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

.main-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(to right, #34d399, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.main-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 2px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Connection Badge */
.connection-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ef4444; /* Default Offline */
    box-shadow: 0 0 8px #ef4444;
}

.connection-badge.online .status-dot {
    background: var(--primary-green);
    box-shadow: 0 0 10px var(--primary-green);
    animation: pulse-glow 2s infinite;
}

.connection-badge.online {
    border-color: rgba(16, 185, 129, 0.2);
}

/* ─── Premium Action Buttons ─────────────────────────────────────────────────── */
.btn-action {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.btn-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
    filter: brightness(1.1);
}

.btn-action:active {
    transform: translateY(1px);
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

/* Logout Button styling override */
.btn-logout {
    background: linear-gradient(135deg, #f87171, #ef4444);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
    text-decoration: none;
    display: inline-block;
}

.btn-logout:hover {
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.35);
}

/* NTP test button override */
#ntp-test-btn {
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.2);
}

#ntp-test-btn:hover {
    box-shadow: 0 6px 18px rgba(14, 165, 233, 0.35);
}

#ntp-test-btn.armed {
    background: linear-gradient(135deg, #f97316, #ea580c);
    box-shadow: 0 4px 12px rgba(234, 88, 12, 0.25);
}

#ntp-test-btn.armed:hover {
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.4);
}

#ntp-test-btn.active {
    background: linear-gradient(135deg, #34d399, #059669);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}

/* Save Schedules button override */
#save-schedules-btn {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

#save-schedules-btn:hover {
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.4);
}

/* ─── Dashboard Grid ────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 25px;
}

@media (max-width: 800px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Card Styling ───────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, border-color 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.card h2 {
    font-size: 1.3rem;
    font-weight: 600;
    border-left: 4px solid var(--primary-green);
    padding-left: 12px;
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* ─── Telemetry Card Details ──────────────────────────────────────────────────── */
.moisture-gauge-container {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 10px auto;
}

.gauge-svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.gauge-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 8px;
}

.gauge-fill {
    fill: none;
    stroke: var(--accent-blue);
    stroke-width: 8px;
    stroke-linecap: round;
    stroke-dasharray: 314;
    stroke-dashoffset: 314;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1), stroke 0.5s ease;
}

.moisture-value-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.moisture-value-overlay .percentage {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.moisture-value-overlay .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stats-row {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.stat-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 16px;
    padding: 15px;
    text-align: center;
}

.stat-val {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-lbl {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ─── Control Card Details ───────────────────────────────────────────────────── */
.manual-toggle-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.15);
    padding: 15px 25px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

.toggle-label {
    font-weight: 600;
    font-size: 1.05rem;
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 32px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #3f3f46;
    transition: .4s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.slider:before {
    position: absolute;
    content: "";
    height: 24px;
    width: 24px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

input:checked + .slider {
    background-color: var(--primary-green);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

input:checked + .slider:before {
    transform: translateX(28px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Pump Status Panel */
.pump-status-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 20px;
    padding: 30px 20px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: background 0.3s ease;
}

.pump-status-panel.active {
    background: rgba(16, 185, 129, 0.08);
    border-color: rgba(16, 185, 129, 0.2);
}

.pump-icon-container {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s, transform 0.3s;
}

.pump-status-panel.active .pump-icon-container {
    background: var(--primary-green);
    box-shadow: 0 0 15px var(--primary-green);
    animation: rotate-pump 2.5s linear infinite;
}

.pump-icon {
    width: 32px;
    height: 32px;
    fill: var(--text-secondary);
    transition: fill 0.3s;
}

.pump-status-panel.active .pump-icon {
    fill: #000;
}

.pump-status-text {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.pump-status-panel.active .pump-status-text {
    color: var(--primary-green);
}

/* ─── Pump Speed Range Slider ───────────────────────────────────────────────── */
.speed-slider-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.speed-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.speed-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-green);
}

.speed-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 8px;
    border-radius: 5px;
    background: #27272a;
    outline: none;
    transition: background 0.3s;
}

.speed-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-green);
    transition: transform 0.1s;
}

.speed-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.speed-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-green);
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-green);
    border: none;
    transition: transform 0.1s;
}

.speed-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
}

.test-container {
    margin-top: 10px;
    border-color: rgba(14, 165, 233, 0.15) !important;
}

/* ─── Custom Schedules Layout ────────────────────────────────────────────────── */
.custom-schedules-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.schedule-row {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 20px;
    transition: border-color 0.3s;
}

.schedule-row.active {
    border-color: rgba(16, 185, 129, 0.15);
}

.schedule-header {
    margin-bottom: 15px;
}

.schedule-name {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.schedule-enable {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.schedule-enable input {
    display: none;
}

.checkbox-custom {
    width: 22px;
    height: 22px;
    border: 2px solid var(--text-secondary);
    border-radius: 6px;
    display: inline-block;
    position: relative;
    transition: all 0.3s ease;
}

.schedule-enable input:checked + .checkbox-custom {
    border-color: var(--primary-green);
    background: var(--primary-green);
    box-shadow: 0 0 8px var(--primary-green);
}

.schedule-enable input:checked + .checkbox-custom::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 2px;
    width: 6px;
    height: 11px;
    border: solid black;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.schedule-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 500px) {
    .schedule-inputs {
        grid-template-columns: 1fr;
    }
}

.input-box {
    display: flex;
    flex-direction: column;
}

.input-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.schedule-inputs input {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 10px 15px;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s;
}

.schedule-inputs input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 8px rgba(14, 165, 233, 0.2);
}

.schedule-actions-row {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

/* Grid layout adjustments to make Schedule Card spanning full width if single column */
.schedule-card {
    grid-column: span 2;
}

@media (max-width: 800px) {
    .schedule-card {
        grid-column: span 1;
    }
}

/* ─── Footer / Clock Styling ─────────────────────────────────────────────────── */
.main-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    padding: 15px 30px;
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.footer-info {
    display: flex;
    gap: 10px;
}

.clock-display {
    font-weight: 600;
    background: rgba(0, 0, 0, 0.25);
    padding: 6px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

/* ─── Animations ────────────────────────────────────────────────────────────── */
@keyframes pulse-glow {
    0% {
        box-shadow: 0 0 6px var(--primary-green);
        opacity: 0.8;
    }
    50% {
        box-shadow: 0 0 14px var(--primary-green);
        opacity: 1;
    }
    100% {
        box-shadow: 0 0 6px var(--primary-green);
        opacity: 0.8;
    }
}

@keyframes rotate-pump {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
