/* ═══════════════════════════════════════════════════════════════════
   EZY Workshop Agent — Stylesheet
   Design: Clean, professional, large touch targets, workshop-friendly
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand colors */
  --ezy-blue: #0066cc;
  --ezy-blue-dark: #004d99;
  --ezy-blue-light: #e6f0ff;

  /* UI colors */
  --bg-dark: #1a1a2e;
  --bg-header: #16213e;
  --bg-chat: #f5f6fa;
  --bg-white: #ffffff;
  --bg-input: #ffffff;

  /* Message bubbles */
  --bubble-agent: #ffffff;
  --bubble-agent-border: #e2e8f0;
  --bubble-user: #0066cc;
  --bubble-user-text: #ffffff;

  /* Status */
  --status-online: #22c55e;
  --status-offline: #ef4444;
  --status-pending: #f59e0b;

  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --text-white: #ffffff;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Typography */
  --font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-base: 18px;
  --font-size-sm: 15px;
  --font-size-lg: 20px;
  --font-size-xl: 24px;

  /* Borders */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 50%;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.12);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.16);

  /* Layout */
  --header-height: 64px;
  --input-height: 72px;
}

html, body {
  height: 100%;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-chat);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────────── */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--header-height);
  background: var(--bg-header);
  color: var(--text-white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-md);
  box-shadow: var(--shadow-md);
}

.header-left, .header-right {
  flex: 1;
  display: flex;
  align-items: center;
}

.header-right {
  justify-content: flex-end;
}

.header-center {
  flex: 1;
  display: flex;
  justify-content: center;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo {
  height: 36px;
  width: auto;
}

.brand-name {
  font-size: var(--font-size-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Session badge */
.session-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  background: rgba(255,255,255,0.12);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.session-badge.morning {
  border: 2px solid #f59e0b;
}

.session-badge.eod {
  border: 2px solid #22c55e;
}

.session-date {
  opacity: 0.7;
  font-weight: 400;
}

/* Status bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--font-size-sm);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.status-dot.online { background: var(--status-online); }
.status-dot.offline { background: var(--status-offline); }
.status-dot.pending { background: var(--status-pending); }

.status-text {
  opacity: 0.8;
  font-size: 13px;
}

/* ── Main Chat Area ───────────────────────────────────────────────── */
#chat-container {
  flex: 1;
  margin-top: var(--header-height);
  margin-bottom: var(--input-height);
  overflow-y: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-md);
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding-bottom: var(--space-lg);
}

/* ── Message Bubbles ──────────────────────────────────────────────── */
.message {
  display: flex;
  gap: var(--space-sm);
  animation: fadeInUp 0.3s ease-out;
}

.message.agent {
  align-self: flex-start;
  max-width: 85%;
}

.message.user {
  align-self: flex-end;
  max-width: 75%;
  flex-direction: row-reverse;
}

.message-bubble {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  line-height: 1.6;
  word-wrap: break-word;
}

.message.agent .message-bubble {
  background: var(--bubble-agent);
  border: 1px solid var(--bubble-agent-border);
  border-bottom-left-radius: var(--space-xs);
  box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
  background: var(--bubble-user);
  color: var(--bubble-user-text);
  border-bottom-right-radius: var(--space-xs);
  box-shadow: var(--shadow-sm);
}

.message-bubble strong { font-weight: 700; }

.message-bubble ul, .message-bubble ol {
  padding-left: var(--space-lg);
  margin: var(--space-sm) 0;
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-sm) 0;
  font-size: var(--font-size-sm);
}

.message-bubble th, .message-bubble td {
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--bubble-agent-border);
  text-align: left;
}

.message-bubble th {
  background: var(--ezy-blue-light);
  font-weight: 600;
}

.message-time {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--space-xs);
}

.message.user .message-time {
  text-align: right;
  color: rgba(255,255,255,0.6);
}

/* ── Typing Indicator ─────────────────────────────────────────────── */
.typing-indicator {
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  max-width: 800px;
  margin: 0 auto;
}

.typing-dots {
  display: flex;
  gap: 5px;
  padding: var(--space-md);
  background: var(--bubble-agent);
  border-radius: var(--radius-md);
  border: 1px solid var(--bubble-agent-border);
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Quick Reply Area ─────────────────────────────────────────────── */
.quick-reply-area {
  position: fixed;
  bottom: var(--input-height);
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-white);
  border-top: 1px solid var(--bubble-agent-border);
  padding: var(--space-md);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.06);
  animation: slideUp 0.2s ease-out;
}

.quick-reply-buttons {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
}

.btn-quick {
  min-height: 52px;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  border: 2px solid var(--ezy-blue);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--ezy-blue);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-quick:hover, .btn-quick:active {
  background: var(--ezy-blue);
  color: var(--text-white);
}

.btn-quick.confirm { border-color: #22c55e; color: #16a34a; }
.btn-quick.confirm:hover, .btn-quick.confirm:active { background: #22c55e; color: white; }

.btn-quick.reject { border-color: #ef4444; color: #dc2626; }
.btn-quick.reject:hover, .btn-quick.reject:active { background: #ef4444; color: white; }

.btn-quick.pend { border-color: #f59e0b; color: #d97706; }
.btn-quick.pend:hover, .btn-quick.pend:active { background: #f59e0b; color: white; }

/* Assembler grid */
.assembler-grid {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
}

.assembler-grid .btn-quick {
  width: 100%;
  text-align: center;
}

/* Progress slider */
.progress-slider-container {
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

.progress-slider-container label {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

.progress-slider-container input[type="range"] {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: #e2e8f0;
  border-radius: 4px;
  outline: none;
}

.progress-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--ezy-blue);
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

.progress-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--ezy-blue);
  min-width: 60px;
  text-align: center;
}

.btn-set-progress {
  min-height: 52px;
  padding: var(--space-sm) var(--space-xl);
  font-size: var(--font-size-base);
  font-weight: 600;
  background: var(--ezy-blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-set-progress:hover { background: var(--ezy-blue-dark); }

/* Yes / No buttons */
.yes-no-buttons {
  max-width: 400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.btn-yes {
  min-height: 60px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-no {
  min-height: 60px;
  font-size: var(--font-size-lg);
  font-weight: 700;
  background: #ef4444;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-yes:hover { background: #16a34a; }
.btn-no:hover { background: #dc2626; }

/* ── Batch Confirm Modal ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  animation: fadeIn 0.2s ease;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  max-width: 700px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

#changes-table-container table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-sm);
}

#changes-table-container th,
#changes-table-container td {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--bubble-agent-border);
  text-align: left;
}

#changes-table-container th {
  background: var(--ezy-blue-light);
  font-weight: 600;
}

#changes-table-container tr:nth-child(even) {
  background: #f8fafc;
}

#changes-table-container input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.change-unit {
  font-weight: 600;
  font-family: monospace;
}

.modal-actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}

/* ── No Session Screen ────────────────────────────────────────────── */
.no-session-screen {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--bg-chat);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.no-session-content h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-md);
}

.no-session-content p {
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
  font-size: var(--font-size-lg);
}

/* ── Input Bar ────────────────────────────────────────────────────── */
footer#input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  height: var(--input-height);
  background: var(--bg-white);
  border-top: 1px solid var(--bubble-agent-border);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.04);
}

.input-wrapper {
  flex: 1;
}

#chat-input {
  width: 100%;
  min-height: 48px;
  max-height: 120px;
  padding: var(--space-sm) var(--space-md);
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  border: 2px solid var(--bubble-agent-border);
  border-radius: var(--radius-sm);
  resize: none;
  outline: none;
  line-height: 1.5;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: var(--ezy-blue);
}

#chat-input::placeholder {
  color: var(--text-muted);
}

/* Voice button */
.btn-voice {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-full);
  background: #e2e8f0;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-voice:hover {
  background: #cbd5e1;
}

.btn-voice.recording {
  background: #ef4444;
  color: white;
  animation: pulse 1.5s ease-in-out infinite;
}

.btn-voice .mic-icon {
  width: 24px;
  height: 24px;
}

/* Send button */
.btn-send {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-full);
  background: var(--ezy-blue);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-send:hover { background: var(--ezy-blue-dark); }
.btn-send:disabled { background: #cbd5e1; cursor: not-allowed; }

.btn-send .send-icon {
  width: 22px;
  height: 22px;
}

/* ── Shared Button Styles ─────────────────────────────────────────── */
.btn {
  min-height: 48px;
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--font-size-base);
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.btn-primary {
  background: var(--ezy-blue);
  color: white;
}

.btn-primary:hover { background: var(--ezy-blue-dark); }

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-primary);
}

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

.btn-large {
  min-height: 56px;
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-lg);
}

/* ── Utility ──────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Animations ───────────────────────────────────────────────────── */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(239, 68, 68, 0); }
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root {
    --font-size-base: 16px;
    --header-height: 56px;
  }

  .brand-name { font-size: var(--font-size-base); }

  .message.agent, .message.user {
    max-width: 92%;
  }

  .assembler-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    padding: var(--space-md);
  }
}

@media (max-width: 480px) {
  .header-center { display: none; }

  .session-badge {
    font-size: 12px;
  }

  .assembler-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .yes-no-buttons {
    gap: var(--space-sm);
  }
}

/* ── Scrollbar ────────────────────────────────────────────────────── */
#chat-container::-webkit-scrollbar {
  width: 6px;
}

#chat-container::-webkit-scrollbar-track {
  background: transparent;
}

#chat-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

#chat-container::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Toast Notifications ─────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: var(--font-size-sm);
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-info {
  background: var(--ezy-blue);
  color: white;
}

.toast-success {
  background: #16a34a;
  color: white;
}

.toast-error {
  background: #dc2626;
  color: white;
}
