/* Agri Smart 4.0 — Irrigation Dashboard Styles */
@import url('app.css');

.dash-body {
  min-height: 100vh;
  background: var(--bg);
  padding-bottom: 20px;
}

.dash-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(7,17,12,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
}

.dash-header .top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dash-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.dash-header .brand img { width: 28px; height: 28px; }
.dash-header .brand span {
  font-family: 'Orbitron', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0,200,83,0.08);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px 4px 6px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.user-btn .av {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #003d16;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.7rem;
}

.status-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 0.8rem; color: var(--text-secondary);
  background: rgba(0,0,0,0.2);
  padding: 4px 12px; border-radius: 20px;
  border: 1px solid var(--border);
}

.status-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
}
.status-pill .dot.on { background: var(--primary); box-shadow: 0 0 8px var(--primary); }
.status-pill .dot.off { background: var(--danger); box-shadow: 0 0 6px var(--danger); }

/* Dropdown */
.dropdown { position: relative; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 170px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 12px;
  z-index: 100; padding: 4px 0; box-shadow: var(--shadow);
}
.dropdown-menu.show { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 10px 14px; border: none; background: none;
  color: var(--text); font-size: 0.85rem; text-align: left; cursor: pointer;
  text-decoration: none; font-family: inherit;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: rgba(0,200,83,0.08); }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ESP Selector */
.esp-sel {
  max-width: 700px; margin: 14px auto 0; padding: 0 16px;
}
.esp-sel label {
  display: block; font-size: 0.8rem; color: var(--text-secondary);
  margin-bottom: 6px; font-weight: 500;
}
.esp-sel select {
  width: 100%; padding: 11px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; color: var(--text); font-size: 0.95rem;
  outline: none; font-family: inherit;
}
.esp-sel select:focus { border-color: var(--primary); }

/* LCD Panel */
.lcd {
  max-width: 700px; margin: 14px auto; padding: 0 16px;
}
.lcd-inner {
  background: #000; border: 2px solid var(--border);
  border-radius: 16px; padding: 18px 16px; text-align: center;
  box-shadow: inset 0 0 24px rgba(0,0,0,0.8); position: relative;
}
.lcd-esp {
  position: absolute; top: 10px; right: 14px;
  font-size: 0.7rem; color: var(--text-muted);
}
.lcd-status {
  font-size: 0.85rem; font-weight: 700; letter-spacing: 1px;
  margin-bottom: 4px;
}
.lcd-status.online { color: var(--primary); }
.lcd-status.offline { color: var(--danger); }
.lcd-status.running { color: var(--primary); animation: blink 1s infinite; }
.lcd-status.waiting { color: var(--warning); }
@keyframes blink { 50% { opacity: 0.5; } }

.lcd-timer {
  font-size: 2.8rem; font-family: 'Courier New', monospace;
  font-weight: 700; color: var(--primary); margin: 4px 0;
}
.lcd-timer.stopped { color: var(--text-muted); }

.lcd-info { font-weight: 600; color: var(--accent); font-size: 1.05rem; }
.lcd-sub { color: var(--warning); font-size: 0.85rem; margin-top: 2px; }

.lcd-bar {
  margin-top: 12px; height: 6px; background: #1a2a1e;
  border-radius: 4px; overflow: hidden;
}
.lcd-bar .fill {
  height: 100%; background: var(--primary); width: 0%;
  transition: width 1s linear;
}

.sensor-row {
  display: flex; justify-content: center; gap: 14px;
  margin-top: 8px; font-size: 0.72rem; color: var(--text-muted);
  flex-wrap: wrap;
}
.sensor-row .v { font-weight: 700; }
.sensor-row .v.c { color: var(--primary); }
.sensor-row .v.p { color: var(--warning); }
.sensor-row .v.pr { color: #ff9100; }

/* Tabs */
.tabs {
  max-width: 700px; margin: 0 auto 12px; padding: 0 16px;
  display: flex; background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.tab {
  flex: 1; padding: 12px 4px; text-align: center;
  font-size: 0.8rem; font-weight: 500; color: var(--text-muted);
  cursor: pointer; transition: all 0.2s; border: none; background: none;
  font-family: inherit;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.02); }
.tab.active {
  color: var(--primary); background: rgba(0,200,83,0.08);
  font-weight: 600; border-bottom: 2px solid var(--primary);
}

.tab-pane { display: none; max-width: 700px; margin: 0 auto; padding: 0 16px; }
.tab-pane.active { display: block; }

/* Cards & forms */
.d-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 14px;
}

.grid-2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px;
}
@media (min-width: 560px) {
  .grid-2 { grid-template-columns: repeat(4, 1fr); }
}

.field label {
  display: block; font-size: 0.72rem; color: var(--text-secondary);
  margin-bottom: 4px; font-weight: 500;
}
.field input {
  width: 100%; padding: 10px; border-radius: 8px;
  border: 1px solid var(--border); background: rgba(0,20,10,0.5);
  color: var(--text); text-align: center; font-size: 1rem;
  outline: none; font-family: inherit;
}
.field input:focus { border-color: var(--primary); }

.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; padding: 13px; font-size: 0.9rem; }

.btn-start {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #003d16; border: none; border-radius: 10px;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-stop {
  background: linear-gradient(135deg, var(--danger), #c62828);
  color: #fff; border: none; border-radius: 10px;
  font-weight: 700; cursor: pointer; font-family: inherit;
}
.btn-start:disabled, .btn-stop:disabled { opacity: 0.35; cursor: not-allowed; }

/* Valve selector */
.valve-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 12px 0;
}
.vbtn {
  padding: 9px 2px; border: 1px solid var(--border);
  background: rgba(0,20,10,0.5); color: var(--text);
  border-radius: 8px; cursor: pointer; font-size: 0.85rem;
  font-weight: 500; transition: all 0.15s; font-family: inherit;
}
.vbtn.selected { background: var(--primary); color: #003d16; border-color: var(--primary); font-weight: 700; }
.vbtn.cyc { background: #12301a; border-color: #2e7d32; color: #9be7a6; }
.vbtn.done { background: #161d17; border-color: #2b3a2d; color: #6b7d6e; text-decoration: line-through; }
.vbtn.current { background: #ff9800; border-color: #ffb74d; color: #000; font-weight: 700; animation: curPulse 1.2s infinite; }
@keyframes curPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(255,152,0,.6); }
  50% { box-shadow: 0 0 10px 3px rgba(255,152,0,.85); }
}
.vbtn:disabled { opacity: 0.3; cursor: not-allowed; }

.selected-list {
  background: rgba(0,0,0,0.25); padding: 10px; border-radius: 8px;
  margin: 10px 0; font-size: 0.85rem; min-height: 36px;
  border-left: 3px solid var(--primary);
}

/* Manual controls */
.ctrl-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px;
}
.ctrl-btn {
  padding: 12px 4px; border: 1px solid var(--border);
  background: rgba(0,20,10,0.5); color: var(--text-muted);
  border-radius: 10px; cursor: pointer; text-align: center;
  font-size: 0.72rem; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all 0.2s; font-family: inherit;
}
.ctrl-btn .ic { font-size: 1.2rem; }
.ctrl-btn.on {
  border-color: var(--primary); background: rgba(0,200,83,0.15);
  color: var(--primary); box-shadow: 0 0 8px rgba(0,200,83,0.2);
}
.ctrl-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.section-lbl {
  font-size: 0.78rem; font-weight: 600; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}

.cfg-row {
  display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px;
  align-items: end; margin-bottom: 12px;
}
@media (max-width: 480px) { .cfg-row { grid-template-columns: 1fr 1fr; } }

.btn-save {
  padding: 11px 14px; border-radius: 8px; border: 1px solid rgba(0,200,83,0.3);
  background: rgba(0,200,83,0.12); color: var(--primary);
  font-weight: 600; cursor: pointer; font-size: 0.82rem; font-family: inherit;
}
.btn-save:hover { background: var(--primary); color: #003d16; }

/* Logs */
.log-head {
  display: flex; justify-content: space-between; align-items: center;
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 10px; font-size: 0.85rem;
}
.log-box {
  background: #000; border: 1px solid var(--border); border-radius: 10px;
  height: 320px; overflow-y: auto; padding: 10px;
  font-family: Consolas, monospace; font-size: 0.8rem;
}
.log-entry {
  margin-bottom: 2px; padding: 3px 6px;
  background: rgba(0,15,8,0.6); border-radius: 3px;
  border-left: 3px solid transparent;
}
.log-entry.START { border-left-color: var(--primary); }
.log-entry.STOP { border-left-color: var(--danger); }
.no-logs { color: var(--text-muted); text-align: center; padding: 20px; font-style: italic; }

/* Toast */
.toast-box {
  position: fixed; bottom: 24px; left: 16px; right: 16px; z-index: 999;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--surface);
  border: 1px solid var(--primary); color: var(--text);
  padding: 12px 18px; border-radius: 12px; font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); max-width: 400px; text-align: center;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Login overlay (fallback) */
.login-ov {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,0.95); display: flex;
  justify-content: center; align-items: center;
  backdrop-filter: blur(6px);
}
.login-ov.hidden { display: none; }
