/* ================================================================
   Ineema Pump Control Dashboard — Styles
   ================================================================
   Dark-themed, responsive dashboard for IoT pump monitoring.
   Extracted from the monolithic Flask template for maintainability.
   ================================================================ */

/* ── Reset & Base ──────────────────────────────────────────────── */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  background: #0a0a0f;
  color: #e0e0e0;
  min-height: 100vh;
}

/* ── Layout ────────────────────────────────────────────────────── */

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ── Header ────────────────────────────────────────────────────── */

.header {
  text-align: center;
  padding: 30px 0;
  border-bottom: 1px solid #1a1a2e;
  margin-bottom: 30px;
}

.header h1 {
  font-size: 2.2em;
  font-weight: 700;
  background: linear-gradient(135deg, #00d2ff, #7b2ff7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.header p {
  color: #666;
  font-size: 1em;
}

/* ── Status Bar ────────────────────────────────────────────────── */

.status-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 15px;
  background: #111122;
  border-radius: 12px;
  margin-bottom: 25px;
}

.status-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #ff4444;
  box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
  transition: all 0.3s ease;
}

.status-indicator.connected {
  background: #00cc66;
  box-shadow: 0 0 10px rgba(0, 204, 102, 0.5);
}

.status-text {
  font-size: 1.1em;
  font-weight: 500;
}

/* ── Control Buttons ───────────────────────────────────────────── */

.controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 25px;
  flex-wrap: wrap;
}

.btn {
  padding: 10px 22px;
  border: none;
  border-radius: 8px;
  font-family: "Inter", sans-serif;
  font-size: 0.95em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-start {
  background: linear-gradient(135deg, #00cc66, #00aa55);
  color: white;
}

.btn-stop {
  background: linear-gradient(135deg, #ff4444, #cc3333);
  color: white;
}

.btn-refresh {
  background: linear-gradient(135deg, #00aaff, #0088cc);
  color: white;
}

.btn-export {
  background: linear-gradient(135deg, #ff9900, #cc7700);
  color: white;
}

.btn-text {
  background: transparent;
  color: #888;
  padding: 10px 15px;
}

.btn-text:hover {
  color: #fff;
  transform: none;
  box-shadow: none;
}

/* ── Stats Grid ────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}

.stat-card {
  background: #111122;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  border: 1px solid #1a1a2e;
  transition: all 0.3s ease;
}

.stat-card:hover {
  border-color: #00d2ff;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0, 210, 255, 0.1);
}

.stat-icon {
  font-size: 1.8em;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.8em;
  font-weight: 700;
  color: #00d2ff;
}

.stat-label {
  font-size: 0.85em;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 5px;
}

/* ── Association Management ────────────────────────────────────── */

.association-panel {
  background: #111122;
  border-radius: 12px;
  padding: 25px;
  margin-bottom: 25px;
  border: 1px solid #1a1a2e;
}

.association-panel h2 {
  font-size: 1.3em;
  margin-bottom: 20px;
  color: #00d2ff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.association-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.association-controls select {
  padding: 10px 15px;
  background: #1a1a2e;
  border: 1px solid #2a2a3e;
  border-radius: 8px;
  color: #e0e0e0;
  font-family: "Inter", sans-serif;
  font-size: 0.9em;
  cursor: pointer;
}

.association-controls select:focus {
  outline: none;
  border-color: #00d2ff;
}

.association-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-create {
  background: linear-gradient(135deg, #7b2ff7, #5500cc);
  color: white;
}

.btn-delete {
  background: linear-gradient(135deg, #ff4444, #cc0000);
  color: white;
  font-size: 0.85em;
  padding: 6px 12px;
}

.btn-save {
  background: linear-gradient(135deg, #00cc66, #009944);
  color: white;
}

.btn-clear {
  background: linear-gradient(135deg, #ff6600, #cc5500);
  color: white;
}

/* Current associations display */
.current-associations {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #1a1a2e;
}

.current-associations h3 {
  font-size: 1em;
  color: #888;
  margin-bottom: 10px;
}

.association-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 15px;
  background: #0d0d1a;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid #1a1a2e;
  transition: all 0.2s ease;
  cursor: pointer;
}

.association-item:hover {
  border-color: #00d2ff;
}

.association-item.selected {
  border-color: #7b2ff7;
  background: #15152a;
}

.association-details {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.association-sensor {
  color: #00d2ff;
  font-weight: 500;
}

.association-pump {
  color: #7b2ff7;
  font-size: 0.9em;
}

.valve-badge {
  background: #1a1a2e;
  color: #888;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.8em;
}

/* Available items lists */
.available-section {
  margin-top: 15px;
}

.available-section h3 {
  font-size: 1em;
  color: #888;
  margin-bottom: 10px;
}

.available-list {
  max-height: 200px;
  overflow-y: auto;
  padding-right: 5px;
}

/* ── Content Panels ────────────────────────────────────────────── */

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.panel {
  background: #111122;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #1a1a2e;
}

.panel h2 {
  font-size: 1.2em;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid #1a1a2e;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Log Panel ─────────────────────────────────────────────────── */

.log-container {
  max-height: 400px;
  overflow-y: auto;
  font-family: "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.85em;
  padding: 10px;
  background: #0a0a15;
  border-radius: 8px;
}

.log-entry {
  padding: 4px 0;
  border-bottom: 1px solid #0d0d1a;
}

.log-timestamp {
  color: #555;
  margin-right: 8px;
}

.log-info {
  color: #00cc66;
}
.log-warning {
  color: #ffaa00;
}
.log-error {
  color: #ff4444;
}
.log-data {
  color: #00aaff;
}

/* ── Data Items (Sensors / Pumps) ──────────────────────────────── */

.data-container {
  max-height: 400px;
  overflow-y: auto;
}

.data-item {
  padding: 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  border: 1px solid #1a1a2e;
  transition: all 0.2s ease;
}

.data-item:hover {
  border-color: #2a2a4e;
  transform: translateX(3px);
}

.data-item.sensor {
  border-left: 3px solid #00d2ff;
  background: linear-gradient(135deg, #0d1117, #111122);
}

.data-item.pump {
  border-left: 3px solid #7b2ff7;
  background: linear-gradient(135deg, #0d1117, #111122);
}

.data-header {
  font-weight: 600;
  margin-bottom: 5px;
}

.data-details {
  font-size: 0.9em;
  color: #888;
  line-height: 1.6;
}

/* ── Refresh Indicator ─────────────────────────────────────────── */

.refresh-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #1a1a2e;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.9em;
  z-index: 1000;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.3s ease;
  pointer-events: none;
}

.refresh-indicator.show {
  opacity: 1;
  transform: translateY(0);
}

/* ── Scrollbar ─────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #0a0a15;
}

::-webkit-scrollbar-thumb {
  background: #2a2a3e;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3a3a5e;
}

/* ── Responsive ────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .panels {
    grid-template-columns: 1fr;
  }
  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .header h1 {
    font-size: 1.6em;
  }
  .association-controls {
    grid-template-columns: 1fr;
  }
}
