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

body {
  font-family: 'Arial', sans-serif;
  background: #f0f4f8;
  height: 100vh;
  overflow: hidden;
}

/* ── Page Layout ── */
.page-wrapper {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ── Sidebar ── */
.sidebar {
  width: 260px;
  background: #1e1b4b;
  color: white;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 24px;
  font-weight: bold;
  color: white;
  margin-bottom: 4px;
}

.sidebar-tagline {
  font-size: 12px;
  color: #a5b4fc;
  line-height: 1.4;
}

.sidebar-divider {
  border-top: 1px solid #3730a3;
  margin: 8px 0;
}

.sidebar-label {
  font-size: 11px;
  color: #818cf8;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.shape-btn {
  padding: 10px 14px;
  background: #312e81;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: background 0.2s;
}

.shape-btn:hover { background: #4338ca; }

.detect-face-btn {
  padding: 12px 14px;
  background: #7c3aed;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: bold;
  margin-top: 8px;
  transition: background 0.2s;
}

.detect-face-btn:hover { background: #6d28d9; }

/* ── Main Area ── */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top Bar ── */
.top-bar {
  background: white;
  padding: 16px 28px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}

.top-bar-title {
  font-size: 20px;
  font-weight: bold;
  color: #1e1b4b;
}

.top-bar-sub {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

/* ── Chat Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
}

.message { max-width: 65%; padding: 12px 16px; border-radius: 16px; line-height: 1.5; }
.message.bot { background: white; align-self: flex-start; box-shadow: 0 1px 4px rgba(0,0,0,0.08); border-radius: 4px 16px 16px 16px; }
.message.user { background: #4f46e5; color: white; align-self: flex-end; border-radius: 16px 4px 16px 16px; }

/* ── Product Grid ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.product-card {
  text-align: center;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}

.product-card:hover { border-color: #4f46e5; box-shadow: 0 4px 12px rgba(79,70,229,0.15); }

.product-card img {
  width: 100%;
  height: 90px;
  object-fit: contain;
  border-radius: 8px;
}

.product-card p { font-size: 11px; margin-top: 6px; color: #475569; }

.try-btn {
  margin-top: 8px;
  padding: 6px 12px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  width: 100%;
}

.try-btn:hover { background: #4338ca; }

/* ── Chat Input ── */
.chat-input-area {
  display: flex;
  padding: 16px 28px;
  gap: 12px;
  background: white;
  border-top: 1px solid #e2e8f0;
}

.chat-input-area input[type="text"] {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  outline: none;
  font-size: 14px;
}

.chat-input-area input:focus { border-color: #4f46e5; }

.chat-input-area button {
  padding: 12px 24px;
  background: #4f46e5;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}

.chat-input-area button:hover { background: #4338ca; }

/* ── Modal ── */
.modal {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal.hidden { display: none; }

.modal-content {
  background: white;
  border-radius: 16px;
  padding: 28px;
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 14px; right: 18px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #64748b;
}

.modal-content h3 { margin-bottom: 16px; font-size: 18px; color: #1e293b; }

.tryon-tabs { display: flex; gap: 8px; margin-bottom: 16px; }

.tab-btn {
  flex: 1;
  padding: 10px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.tab-btn.active { border-color: #4f46e5; background: #4f46e5; color: white; }

.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
}

video { width: 100%; display: block; transform: scaleX(-1); }

#overlayCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  transform: scaleX(-1);
}

.photo-wrapper { width: 100%; margin-bottom: 12px; }
#photoCanvas { width: 100%; border-radius: 12px; border: 1px solid #e2e8f0; }

.start-btn, .stop-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  margin-right: 8px;
}

.start-btn { background: #22c55e; color: white; }
.stop-btn { background: #ef4444; color: white; }

.upload-label {
  display: inline-block;
  padding: 10px 20px;
  background: #4f46e5;
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

#photoInput { display: none; }

.detect-btn {
  margin-top: 10px;
  margin-left: 10px;
  padding: 10px 20px;
  background: #7c3aed;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.glasses-selector {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

.glass-thumb {
  width: 80px;
  height: 50px;
  object-fit: contain;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  padding: 4px;
  transition: border 0.2s;
}

.glass-thumb.selected { border-color: #4f46e5; }

.result-badge {
  display: inline-block;
  padding: 4px 12px;
  background: #4f46e5;
  color: white;
  border-radius: 20px;
  font-size: 13px;
  font-weight: bold;
  margin-top: 8px;
}

.hidden { display: none; }

.photo-prompt {
  text-align: center;
  padding: 30px;
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #f8fafc;
}

.photo-prompt p {
  color: #64748b;
  margin-bottom: 16px;
  font-size: 15px;
}

.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.upload-label.small {
  padding: 8px 14px;
  font-size: 12px;
}

.save-btn {
  padding: 10px 16px;
  background: #22c55e;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.save-btn:hover { background: #16a34a; }

.ar-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-bottom: 12px;
}

#video {
  width: 100%;
  display: block;
  transform: scaleX(-1);
}

#arCanvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.tracking-status {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.5);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  pointer-events: none;
}

.camera-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.snap-btn {
  padding: 10px 16px;
  background: #f59e0b;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
}

.snap-btn:hover { background: #d97706; }

.sidebar-logo-img {
  width: 130px;
  height: 65px;
  object-fit: contain;
  mix-blend-mode: screen;
}

.topbar-logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

/* ── Mobile Responsive ───────────────────────────────── */
@media (max-width: 768px) {

  /* Hide sidebar on mobile */
  .sidebar {
    display: none;
  }

  /* Full width main area */
  .main-area {
    width: 100%;
  }

  /* Top bar */
  .top-bar {
    padding: 10px 16px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .topbar-logo-img {
    height: 30px;
  }

  .top-bar-sub {
    display: none;
  }

  /* Chat messages */
  .chat-messages {
    padding: 12px 16px;
  }

  .message {
    max-width: 90%;
  }

  /* Product grid 2 columns on mobile */
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Chat input */
  .chat-input-area {
    padding: 10px 12px;
    gap: 8px;
  }

  .chat-input-area input[type="text"] {
    font-size: 16px;
  }

  /* Modal full screen on mobile */
  .modal-content {
    width: 100%;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    padding: 16px;
    overflow-y: auto;
  }

  .modal {
    align-items: flex-end;
  }

  /* AR camera full width */
  .ar-wrapper {
    width: 100%;
  }

  /* Glasses selector scrollable */
  .glasses-selector {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 8px;
  }

  .glass-thumb {
    flex-shrink: 0;
  }

  /* Camera controls */
  .camera-controls {
    flex-wrap: wrap;
  }

  .start-btn, .stop-btn, .snap-btn {
    flex: 1;
    font-size: 12px;
    padding: 8px;
  }

  .photo-actions {
    flex-wrap: wrap;
  }

  .upload-label.small,
  .detect-btn,
  .save-btn {
    flex: 1;
    text-align: center;
    font-size: 12px;
  }
}

.hamburger {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #1e1b4b;
  padding: 4px 8px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  align-self: flex-end;
  margin-bottom: 8px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

.sidebar-overlay.visible {
  display: block;
}

@media (max-width: 768px) {
  .hamburger {
    display: block;
  }

  .sidebar-close {
    display: block;
  }

  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    height: 100%;
    z-index: 100;
    transition: left 0.3s ease;
    display: flex !important;
  }

  .sidebar.open {
    left: 0;
  }

  .top-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}
