/* Palanta Monitor - CSS */
:root {
    --bg: #1a1a2e;
    --bg2: #16213e;
    --card: #0f3460;
    --accent: #4ecca3;
    --accent2: #e94560;
    --text: #eee;
    --text2: #aaa;
    --on: #4ecca3;
    --off: #666;
    --warn: #f0a500;
    --hot: #e94560;
}

* { 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);
    min-height: 100vh;
}

header {
    background: var(--bg2);
    border-bottom: 2px solid var(--accent);
    padding: 0.8rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 { font-size: 1.3rem; color: var(--accent); }

nav { display: flex; gap: 0.8rem; align-items: center; }

.user-badge {
    background: var(--card);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

main {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
}

/* Status bar */
.status-bar {
    background: var(--bg2);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text2);
    margin-bottom: 1rem;
    text-align: center;
}
.status-bar.ok { border-left: 3px solid var(--on); }
.status-bar.error { border-left: 3px solid var(--accent2); }

/* Sections */
.section {
    margin-bottom: 2rem;
}
.section h2 {
    font-size: 1rem;
    color: var(--accent);
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}
.zone-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

/* Zone groups */
.zone-group {
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    padding: 0.6rem;
}
.zone-label {
    font-size: 0.75rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    padding-left: 0.3rem;
}
.zone-cards {
    display: flex;
    gap: 0.6rem;
}
@media (max-width: 600px) {
    .zone-cards { flex-direction: column; }
}

/* Cards */
.card {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
}

.sensor-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--accent);
    transition: border-color 0.3s;
    flex: 1;
}
.sensor-card.warm { border-left-color: var(--warn); }
.sensor-card.hot { border-left-color: var(--hot); }
.sensor-card.offline { border-left-color: var(--accent2); opacity: 0.6; }
.sensor-card.offline .value { color: var(--accent2); font-size: 1.2rem; }

.sensor-card .name {
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 0.3rem;
}
.sensor-card .value {
    font-size: 2rem;
    font-weight: bold;
}
.sensor-card .bar {
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}
.sensor-card .bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.5s ease;
}
.sensor-card.warm .bar-fill { background: var(--warn); }
.sensor-card.hot .bar-fill { background: var(--hot); }

/* Moisture cards */
.moisture-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
    border-left: 4px solid var(--off);
}
.moisture-card.wet { border-left-color: #2196f3; }
.moisture-card.ok { border-left-color: var(--on); }
.moisture-card.dry { border-left-color: var(--accent2); }
.moisture-card .name {
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 0.3rem;
}
.moisture-card .value {
    font-size: 2rem;
    font-weight: bold;
}
.moisture-card .moisture-label {
    font-size: 0.75rem;
    color: var(--text2);
    margin-bottom: 0.3rem;
}
.moisture-card.dry .moisture-label { color: var(--accent2); font-weight: bold; }
.moisture-card .bar {
    height: 4px;
    background: var(--bg);
    border-radius: 2px;
    margin-top: 0.3rem;
    overflow: hidden;
}
.moisture-card .bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--on);
    transition: width 0.5s ease;
}
.moisture-card.wet .bar-fill { background: #2196f3; }
.moisture-card.dry .bar-fill { background: var(--accent2); }
.moisture-card .raw-value {
    font-size: 0.7rem;
    color: #555;
    margin-top: 0.3rem;
}

/* Relay cards */
.relay-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.relay-card .name {
    font-size: 0.85rem;
}
.relay-card .toggle {
    width: 56px;
    height: 28px;
    border-radius: 14px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.3s;
    background: var(--off);
}
.relay-card .toggle.on { background: var(--on); }
.relay-card .toggle::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s;
}
.relay-card .toggle.on::after { transform: translateX(28px); }

/* Plug card */
.plug-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1.2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--off);
}
.plug-card.on { border-left-color: var(--on); }
.plug-card .plug-info .name { font-size: 0.85rem; color: var(--text2); }
.plug-card .plug-info .status { font-size: 1.4rem; font-weight: bold; }
.plug-card .plug-info .temp { font-size: 0.8rem; color: var(--text2); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--accent);
    border-radius: 6px;
    color: var(--accent);
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.btn:hover { background: var(--accent); color: var(--bg); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-primary { background: var(--accent); color: var(--bg); font-weight: bold; }
.btn-primary:hover { background: #3ba884; }
.btn-full { width: 100%; text-align: center; }
.btn-danger { border-color: var(--accent2); color: var(--accent2); }
.btn-danger:hover { background: var(--accent2); color: white; }

/* Login / Setup */
.login-card {
    max-width: 400px;
    margin: 3rem auto;
    padding: 2rem;
}
.login-card h2 { color: var(--accent); margin-bottom: 1.5rem; }

.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.85rem;
    color: var(--text2);
}
.form-group input {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid #333;
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
}
.form-group input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Alerts */
.alert {
    padding: 0.8rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: rgba(233, 69, 96, 0.2); border: 1px solid var(--accent2); }
.alert-success { background: rgba(78, 204, 163, 0.2); border: 1px solid var(--accent); }

/* QR code */
.qr-container {
    text-align: center;
    margin: 1rem 0;
}
.qr-container img { max-width: 200px; border-radius: 8px; }
.secret-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text2);
    margin-bottom: 1rem;
}
.secret-text code {
    background: var(--bg);
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    word-break: break-all;
}

/* Chart */
.chart-container {
    position: relative;
    width: 100%;
    height: 380px;
}
.chart-controls {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.chart-controls select {
    background: var(--bg2);
    color: var(--text);
    border: 1px solid #333;
    border-radius: 4px;
    padding: 0.3rem 0.5rem;
    font-size: 0.85rem;
}

/* System info */
.system-info {
    background: var(--card);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.85rem;
    color: var(--text2);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.5rem;
}
.system-info .info-item span { color: var(--text); font-weight: bold; }

/* Responsive */
@media (max-width: 900px) {
    .zone-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .grid { grid-template-columns: 1fr; }
    .zone-grid { grid-template-columns: 1fr; }
    .sensor-card .value { font-size: 1.5rem; }
    header h1 { font-size: 1.1rem; }
    main { padding: 1rem; }
    .chart-container { height: 250px; }
}
