/* FORI AGV Control Dashboard - AZMO Modern Design System (image_1 style) */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css');
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
  /* AZMO Theme Colors from image_1 */
  --sidebar-gradient: linear-gradient(180deg, #28AE7B 0%, #1E9165 60%, #15734F 100%);
  --sidebar-bg: #22A774;
  --sidebar-hover: rgba(255, 255, 255, 0.1);
  --sidebar-active: #FFFFFF;

  --bg-main: #F4F6F5;
  --bg-card: #FFFFFF;
  --bg-card-subtle: #F8FAFC;

  --text-main: #1E293B;
  --text-muted: #64748B;
  --text-subtle: #94A3B8;

  --primary-green: #22A774;
  --primary-green-dark: #18865C;
  --primary-green-light: #ECFDF5;
  --primary-green-border: #A7F3D0;

  --accent-blue: #3B82F6;
  --accent-blue-light: #EFF6FF;
  --accent-blue-border: #BFDBFE;

  --status-normal: #10B981;
  --status-warning: #F59E0B;
  --status-error: #EF4444;

  --border-color: #E2E8F0;
  --border-color-light: #F1F5F9;

  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 16px -2px rgba(0, 0, 0, 0.04), 0 2px 6px -1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.06), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
  --shadow-glow: 0 0 0 3px rgba(34, 167, 116, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Pretendard', 'Outfit', -apple-system, system-ui, sans-serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* App Container with Green Sidebar */
.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

/* Emerald Green Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-gradient);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.04);
  z-index: 10;
}

.sidebar-header {
  padding: 24px 20px 28px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.logo-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  color: #FFFFFF;
}

.logo-text {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #FFFFFF;
}

.logo-text span {
  color: #A7F3D0;
  font-size: 14px;
  font-weight: 600;
  margin-left: 4px;
}

.sidebar-nav {
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #FFFFFF;
  transform: translateX(3px);
}

.nav-item.active {
  background: #FFFFFF;
  color: var(--primary-green-dark);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sidebar-footer {
  padding: 20px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

/* Main Content Wrapper */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
}

/* Header Navbar */
.top-header {
  height: 64px;
  background: #FFFFFF;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  background: var(--bg-card-subtle);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
}

.pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.pulse-indicator.green {
  background-color: var(--status-normal);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.pulse-indicator.red {
  background-color: var(--status-error);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.env-badge {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.env-badge.sim {
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
}

.env-badge.real {
  background: var(--primary-green-light);
  color: var(--primary-green-dark);
  border: 1px solid var(--primary-green-border);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 34px;
  height: 34px;
  background: var(--primary-green-light);
  color: var(--primary-green-dark);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  border: 2px solid var(--primary-green-border);
}

/* Main Dashboard Layout */
.dashboard-content {
  padding: 28px 32px 40px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 1700px;
  margin: 0 auto;
  width: 100%;
}

.section-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.4px;
}

/* Metric Gauge Summary Section ("Total Condition" derived from image_1) */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.metric-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
}

.metric-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.1;
}

.metric-subtext {
  font-size: 12px;
  color: var(--text-subtle);
  margin-top: 2px;
}

/* SVG Donut Ring Gauge Component */
.ring-gauge-container {
  position: relative;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-gauge-svg {
  transform: rotate(-90deg);
  width: 72px;
  height: 72px;
}

.ring-bg {
  fill: none;
  stroke: #F1F5F9;
  stroke-width: 6;
}

.ring-fill {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease;
}

.ring-fill.green { stroke: var(--primary-green); }
.ring-fill.blue { stroke: var(--accent-blue); }
.ring-fill.amber { stroke: var(--status-warning); }

.ring-center-text {
  position: absolute;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

/* Dashboard Main Grid (2 Columns) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 24px;
}

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

/* Cards (Soft Shadows & Rounded Corners) */
.grid-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.card-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
}

.help-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Map Card */
.map-card {
  height: auto;
}

.canvas-container {
  width: 100%;
  height: 380px;
  background: #F1F5F9;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#map-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Config & Pose Panel */
.config-panel {
  background: var(--bg-card-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.config-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.coord-inputs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-group label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-group input {
  height: 38px;
  padding: 0 10px;
  background: #FFFFFF;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: var(--text-main);
  outline: none;
  transition: all 0.2s ease;
}

.input-group input:focus {
  border-color: var(--primary-green);
  box-shadow: var(--shadow-glow);
}

.pose-panel {
  background: var(--primary-green-light);
  border: 1px solid var(--primary-green-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.pose-panel h3 {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary-green-dark);
  margin-bottom: 4px;
}

.pose-value-display {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary-green-dark);
  text-align: center;
}

/* Battery Panel */
.battery-panel {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* Right Column Panels */
.right-column {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Camera Stream Section */
.camera-container-layout {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .camera-container-layout {
    grid-template-columns: 1fr;
  }
}

.camera-stream-container {
  background: #0F172A;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  aspect-ratio: 4/3;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-stream-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ArUco Panel */
.aruco-info-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aruco-status-badge {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 12px;
  font-weight: 700;
}

.aruco-status-badge.disconnected {
  background: #FEF2F2;
  color: var(--status-error);
  border: 1px solid #FCA5A5;
}

.aruco-status-badge.connected {
  background: var(--primary-green-light);
  color: var(--primary-green-dark);
  border: 1px solid var(--primary-green-border);
}

.aruco-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-row {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-label {
  font-size: 11px;
  color: var(--text-muted);
}

.detail-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

/* Controls & Buttons */
.mode-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.btn {
  height: 40px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.btn-primary.active {
  background: var(--primary-green);
  color: #FFFFFF;
  border-color: var(--primary-green-dark);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(34, 167, 116, 0.3);
}

.btn-secondary {
  background: var(--accent-blue-light);
  color: var(--accent-blue);
  border: 1px solid var(--accent-blue-border);
}

.btn-secondary:hover {
  background: #DBEAFE;
}

.btn-danger {
  background: #FEF2F2;
  color: var(--status-error);
  border: 1px solid #FCA5A5;
}

.btn-danger:hover {
  background: #FEE2E2;
}

.btn-danger.active {
  background: var(--status-error) !important;
  color: #FFFFFF !important;
  border-color: #DC2626 !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.4) !important;
}

/* Telemetry Grid */
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.metric-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px;
  text-align: center;
}

.metric-box .metric-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-box .metric-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

#val-state {
  color: var(--primary-green-dark);
}

/* RPM Bars */
.rpm-panel h3 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.rpm-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rpm-bar-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.wheel-name {
  width: 75px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.bar-container {
  flex: 1;
  height: 8px;
  background: #F1F5F9;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-green), #3B82F6);
  border-radius: 4px;
  transition: width 0.15s ease-out;
}

.rpm-val {
  width: 55px;
  text-align: right;
  font-size: 12px;
  font-weight: 700;
}

/* Mobile & PWA Responsive Styling */
.mobile-hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  font-size: 24px;
  font-weight: 700;
  color: var(--primary-green-dark);
  cursor: pointer;
}

.mobile-close-btn {
  display: none;
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 24px;
  cursor: pointer;
  margin-left: auto;
}

.pwa-install-btn {
  background: var(--primary-green);
  color: #FFFFFF;
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(34, 167, 116, 0.3);
  transition: all 0.2s ease;
}

.mobile-header-title {
  display: none;
  font-size: 16px;
  font-weight: 800;
  color: var(--primary-green-dark);
}

.pwa-install-btn:hover {
  background: var(--primary-green-dark);
  transform: translateY(-1px);
}

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Media Queries (max-width: 768px) */
@media (max-width: 768px) {
  body {
    font-size: 13px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    height: 100vh;
    width: 260px;
    z-index: 100;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.2);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .mobile-hamburger-btn {
    display: flex;
    flex-shrink: 0;
  }

  .mobile-header-title {
    display: inline-block;
    white-space: nowrap;
    margin-left: 6px;
    font-size: 15px;
    font-weight: 800;
    color: var(--primary-green-dark);
  }

  .mobile-close-btn {
    display: block;
  }

  .top-header {
    padding: 0 10px;
    height: 54px;
  }

  .header-left {
    gap: 4px;
    min-width: 0;
  }

  .header-right {
    gap: 4px;
    flex-shrink: 0;
  }

  .page-breadcrumb {
    display: none !important;
  }

  .connection-status {
    padding: 3px 6px;
    font-size: 10px;
    gap: 4px;
    border-radius: var(--radius-full);
  }

  #status-text {
    display: none;
  }

  .pwa-install-btn {
    padding: 4px 8px;
    font-size: 10px;
    white-space: nowrap;
  }

  .dashboard-content {
    padding: 12px;
    gap: 14px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .section-title {
    font-size: 16px;
  }

  /* 1. Top 3 Metrics: Single Horizontal Row (1 Row x 3 Columns) */
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }

  .metric-card {
    padding: 8px 4px;
    border-radius: var(--radius-md);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    overflow: hidden;
  }

  .metric-info {
    align-items: center;
    text-align: center;
    gap: 1px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
  }

  .metric-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  .metric-value {
    font-size: 14px;
    font-weight: 800;
    margin: 0;
    line-height: 1.1;
  }

  .metric-subtext {
    display: none;
  }

  .ring-gauge-container {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
  }

  .ring-gauge-svg {
    width: 32px;
    height: 32px;
  }

  .ring-bg, .ring-fill {
    stroke-width: 4;
  }

  .ring-center-text {
    font-size: 9px;
  }

  /* 2. Vertical Card Stack Order on Mobile */
  .dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
  }

  .grid-card {
    padding: 14px;
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .canvas-container {
    height: 280px;
    width: 100%;
    box-sizing: border-box;
  }

  .config-panel {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    padding: 10px;
  }

  .coord-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .input-group {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .input-group input {
    width: 100%;
    min-width: 0;
    height: 34px;
    font-size: 12px;
    padding: 0 2px;
    text-align: center;
    box-sizing: border-box;
    border-radius: 6px;
  }

  .camera-container-layout {
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .mode-selector {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
  }

  .btn {
    height: 36px;
    padding: 0 6px;
    font-size: 11px;
    box-sizing: border-radius;
  }

  .telemetry-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }

  .metric-box {
    padding: 6px 2px;
    min-width: 0;
    box-sizing: border-box;
  }

  .metric-box .metric-label {
    font-size: 9px;
  }

  .metric-box .metric-value {
    font-size: 11px;
  }
}
