/**
 * css/style.css
 * Modern CAD / GIS Dark-Mode UI Theme for Tata Solar PV Site Map Viewer
 */

:root {
  --bg-dark: #0b1120;
  --panel-bg: rgba(15, 23, 42, 0.85);
  --panel-border: rgba(51, 65, 85, 0.7);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --primary-cyan: #38bdf8;
  --accent-amber: #f59e0b;
  --color-betonne: #16a34a;
  --color-fore: #0284c7;
  --color-pasencore: #64748b;
  --color-nof: #dc2626;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 13px;
  user-select: none;
}

#app-container {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
}

/* Header */
#app-header {
  height: 52px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  z-index: 20;
}

.brand-section h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--primary-cyan);
}

.brand-section .subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

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

.btn {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: var(--primary-cyan);
}

.btn-primary {
  background: rgba(56, 189, 248, 0.15);
  color: var(--primary-cyan);
  border-color: rgba(56, 189, 248, 0.4);
}

.btn-primary:hover {
  background: rgba(56, 189, 248, 0.25);
}

.btn-active, .btn.active {
  background: rgba(56, 189, 248, 0.3);
  border-color: var(--primary-cyan);
  color: #fff;
}

/* KPI Banner */
#kpi-banner {
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 6px 16px;
  overflow-x: auto;
  z-index: 15;
}

.kpi-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(51, 65, 85, 0.5);
  border-radius: 6px;
  font-size: 11px;
  white-space: nowrap;
}

.kpi-chip .chip-label {
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.05em;
}

.kpi-chip .chip-value {
  font-weight: 700;
  font-family: var(--font-mono);
}

.chip-betonne { border-left: 3px solid var(--color-betonne); }
.chip-fore { border-left: 3px solid var(--color-fore); }
.chip-pasencore { border-left: 3px solid var(--color-pasencore); }
.chip-nof { border-left: 3px solid var(--color-nof); }
.chip-chaaba { border-left: 3px solid var(--accent-amber); }

/* Main Workspace */
#main-workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* Sidebar Filter Panel */
#sidebar-filters {
  width: 320px;
  background: var(--panel-bg);
  border-right: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  z-index: 10;
}

.sidebar-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary-cyan);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-box input {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
}

.filter-item input[type="checkbox"], .filter-item input[type="radio"] {
  cursor: pointer;
  accent-color: var(--primary-cyan);
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-betonne { background: var(--color-betonne); }
.dot-fore { background: var(--color-fore); }
.dot-pasencore { background: var(--color-pasencore); }
.dot-nof { background: var(--color-nof); }

.timeline-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-box input[type="range"] {
  width: 100%;
  accent-color: var(--primary-cyan);
  cursor: pointer;
}

.timeline-val-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--primary-cyan);
  font-weight: 600;
}

/* Canvas Area */
#canvas-container {
  flex: 1;
  position: relative;
  background: var(--bg-dark);
}

#map-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Floating CAD Toolbar */
#cad-toolbar {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  gap: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Inspector Floating Card */
#inspector-card {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 290px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: none;
  z-index: 10;
}

.inspector-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-cyan);
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inspector-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.inspector-row .label {
  color: var(--text-muted);
}

.inspector-row .val {
  font-weight: 600;
  font-family: var(--font-mono);
  text-align: right;
}

.status-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.status-betonne { background: rgba(22, 163, 74, 0.2); color: #4ade80; border: 1px solid #16a34a; }
.status-fore { background: rgba(2, 132, 199, 0.2); color: #38bdf8; border: 1px solid #0284c7; }
.status-pasencore { background: rgba(100, 116, 139, 0.2); color: #cbd5e1; border: 1px solid #64748b; }
.status-nof { background: rgba(220, 38, 38, 0.2); color: #f87171; border: 1px solid #dc2626; }

/* Status Bar / Footer */
#app-footer {
  height: 28px;
  background: var(--panel-bg);
  border-top: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  z-index: 20;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.modal-overlay.active {
  display: flex !important;
}

.modal-content {
  background: #0f172a;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.8);
}

.modal-header {
  padding: 16px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid var(--panel-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tracker-piles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tracker-pile-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(30, 41, 59, 0.4);
  border-radius: 4px;
  font-size: 11px;
}

/* Auth Passcode Gate Overlay */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.96), rgba(7, 10, 19, 0.99));
  backdrop-filter: blur(16px);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.auth-overlay.unlocked {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-card {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(56, 189, 248, 0.15);
  border-radius: 14px;
  width: 90%;
  max-width: 440px;
  padding: 32px 28px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: authCardIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardIn {
  from {
    transform: translateY(20px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.auth-icon-badge {
  font-size: 32px;
  margin-bottom: 12px;
  background: rgba(56, 189, 248, 0.1);
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.auth-card h2 {
  font-size: 17px;
  color: var(--primary-cyan);
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.auth-notice {
  font-size: 12px;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.7);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(51, 65, 85, 0.6);
  margin-bottom: 20px;
  width: 100%;
  line-height: 1.4;
}

.auth-input-group {
  display: flex;
  width: 100%;
  gap: 8px;
}

.auth-input-group input {
  flex: 1;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  color: #fff;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input-group input:focus {
  border-color: var(--primary-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.btn-auth {
  background: var(--primary-cyan) !important;
  color: #0b1120 !important;
  font-weight: 700 !important;
  padding: 10px 16px !important;
  border-radius: 8px !important;
  border: none !important;
  cursor: pointer;
  white-space: nowrap;
}

.btn-auth:hover {
  background: #7dd3fc !important;
}

.auth-error {
  color: #ef4444;
  font-size: 12px;
  margin-top: 10px;
  min-height: 18px;
  font-weight: 600;
}

.auth-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 14px;
}

.auth-hint code {
  color: var(--primary-cyan);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-weight: 700;
}

.shake {
  animation: shakeKey 0.4s ease-in-out;
  border-color: #ef4444 !important;
}

@keyframes shakeKey {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}
