/* ═══════════════════════════════════════════
   Lanerm Beauty — Brand Design Tokens & Fonts
   ═══════════════════════════════════════════ */

@font-face {
  font-family: 'Hagrid';
  src: url('../assets/fonts/Hagrid.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Hagrid Trial';
  src: url('../assets/fonts/Hagrid-Trial.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Swear Display';
  src: url('../assets/fonts/SwearDisplay.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg-color: #F5F4F0;
  --text-color: #6B4C2A;
  --accent-color: #8B5E3C;
  --border-color: #D4C5B0;
  --light-surface: #EAE8E2;
  --chart-primary: #6B4C2A;
  --chart-secondary: #8B5E3C;
  --chart-light: #D4C5B0;
  --chart-accent: #A67C52;
  --chart-muted: #EAE8E2;
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: 'Hagrid Trial', 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Hagrid', 'Segoe UI', Tahoma, sans-serif;
}

.font-swear {
  font-family: 'Swear Display', Georgia, serif;
}

.font-hagrid {
  font-family: 'Hagrid', 'Segoe UI', Tahoma, sans-serif;
}

.font-body {
  font-family: 'Hagrid Trial', 'Segoe UI', Tahoma, sans-serif;
}

[dir="rtl"] body,
[dir="rtl"] {
  font-family: 'Hagrid Trial', 'Segoe UI', Tahoma, 'Arial', sans-serif;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--light-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-color);
}

/* Tab transitions */
.tab-content {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  display: none;
}

.tab-content.active {
  opacity: 1;
  transform: translateY(0);
  display: block;
}

/* Collapsible sections */
.collapsible-header {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.collapsible-header:hover {
  background-color: var(--light-surface);
}

.collapsible-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease;
}

.collapsible-body.open {
  max-height: 5000px;
}

/* Chevron rotation */
.chevron {
  transition: transform 0.3s ease;
}

.chevron.rotate {
  transform: rotate(180deg);
}

/* Active tab indicator */
.tab-btn {
  position: relative;
  transition: color 0.2s ease;
}

.tab-btn::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--text-color);
  transition: width 0.3s ease;
}

.tab-btn.active::after {
  width: 100%;
}

/* KPI card hover */
.kpi-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(107, 76, 42, 0.15);
}

/* Folder item */
.folder-item {
  transition: background-color 0.2s ease, border-color 0.2s ease;
  cursor: pointer;
}

.folder-item:hover {
  background-color: var(--light-surface);
}

.folder-item.active {
  background-color: var(--light-surface);
  border-left: 3px solid var(--accent-color);
}

[dir="rtl"] .folder-item.active {
  border-left: none;
  border-right: 3px solid var(--accent-color);
}

/* File card */
.file-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(107, 76, 42, 0.1);
}

/* Buttons */
.btn-brand {
  background-color: var(--text-color);
  color: var(--bg-color);
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.btn-brand:hover {
  background-color: var(--accent-color);
}

.btn-brand:active {
  transform: scale(0.98);
}

/* Timeline */
.timeline-item {
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 40px;
  bottom: -20px;
  width: 2px;
  background-color: var(--border-color);
}

[dir="rtl"] .timeline-item::before {
  left: auto;
  right: 20px;
}

.timeline-item:last-child::before {
  display: none;
}

/* Input styles */
.input-brand {
  border: 1px solid var(--border-color);
  background-color: white;
  color: var(--text-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-brand:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(139, 94, 60, 0.1);
}

/* Language toggle */
.lang-btn {
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lang-btn.active {
  background-color: var(--text-color);
  color: var(--bg-color);
}

/* Mobile bottom nav */
@media (max-width: 768px) {
  .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background-color: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  }
}

/* ═══════════════════════════════════════════
   Chat Widget
   ═══════════════════════════════════════════ */

/* Floating action button */
.chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(107, 76, 42, 0.35);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

[dir="rtl"] .chat-fab {
  right: auto;
  left: 24px;
}

.chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(107, 76, 42, 0.45);
}

.chat-fab-active {
  transform: rotate(0deg) !important;
}

.chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Chat panel */
.chat-panel {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 9998;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 48px rgba(107, 76, 42, 0.2), 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s;
}

[dir="rtl"] .chat-panel {
  right: auto;
  left: 24px;
}

.chat-hidden {
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  pointer-events: none;
  visibility: hidden;
}

.chat-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
  visibility: visible;
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  flex-shrink: 0;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-header-title {
  font-family: 'Hagrid', sans-serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
}

.chat-header-subtitle {
  font-size: 11px;
  opacity: 0.8;
  margin-top: 1px;
}

.chat-clear-btn,
.chat-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  border: none;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.chat-clear-btn:hover,
.chat-close-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-color);
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Welcome */
.chat-welcome-inner {
  text-align: center;
  padding: 20px 8px 8px;
}

.chat-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.chat-welcome-title {
  font-family: 'Hagrid', sans-serif;
  font-size: 16px;
  color: var(--text-color);
  margin-bottom: 6px;
}

.chat-welcome-text {
  font-size: 13px;
  color: var(--accent-color);
  line-height: 1.6;
  margin-bottom: 18px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chat-suggestion-btn {
  font-family: 'Hagrid Trial', sans-serif;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: #fff;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1.3;
}

.chat-suggestion-btn:hover {
  background: var(--text-color);
  color: var(--bg-color);
  border-color: var(--text-color);
  transform: translateY(-1px);
}

/* Message bubbles */
.chat-bubble {
  display: flex;
  gap: 8px;
  max-width: 88%;
  animation: chatFadeIn 0.25s ease;
}

@keyframes chatFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-assistant {
  align-self: flex-start;
}

[dir="rtl"] .chat-user {
  align-self: flex-start;
  flex-direction: row-reverse;
}

[dir="rtl"] .chat-assistant {
  align-self: flex-end;
}

.chat-bubble-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.chat-bubble-content {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
}

.chat-user .chat-bubble-content {
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  border-bottom-right-radius: 4px;
}

[dir="rtl"] .chat-user .chat-bubble-content {
  border-bottom-right-radius: 16px;
  border-bottom-left-radius: 4px;
}

.chat-assistant .chat-bubble-content {
  background: #fff;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

[dir="rtl"] .chat-assistant .chat-bubble-content {
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 4px;
}

.chat-text code {
  background: rgba(107, 76, 42, 0.1);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.chat-text strong {
  font-weight: 600;
}

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 4px;
  padding: 4px 0;
}

.chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-color);
  animation: typingBounce 1.4s infinite;
}

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

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

/* Input area */
.chat-input-area {
  padding: 12px 16px 14px;
  border-top: 1px solid var(--border-color);
  background: #fff;
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 4px 4px 4px 14px;
  transition: border-color 0.2s;
}

[dir="rtl"] .chat-form {
  padding: 4px 14px 4px 4px;
}

.chat-form:focus-within {
  border-color: var(--accent-color);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: 'Hagrid Trial', sans-serif;
  font-size: 13px;
  color: var(--text-color);
  outline: none;
  padding: 6px 0;
}

.chat-input::placeholder {
  color: var(--border-color);
}

.chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--text-color), var(--accent-color));
  color: var(--bg-color);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.15s;
}

.chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.chat-send-btn:not(:disabled):hover {
  transform: scale(1.06);
}

[dir="rtl"] .chat-send-btn svg {
  transform: scaleX(-1);
}

.chat-powered {
  text-align: center;
  font-size: 10px;
  color: var(--border-color);
  margin-top: 8px;
  font-family: 'Hagrid Trial', sans-serif;
}

/* Mobile adjustments for chat */
@media (max-width: 768px) {
  .chat-fab {
    bottom: 80px;
  }

  [dir="rtl"] .chat-fab {
    left: 16px;
  }

  .chat-fab:not([dir="rtl"]) {
    right: 16px;
  }

  .chat-panel {
    bottom: 148px;
    right: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    height: calc(100vh - 200px);
    max-height: calc(100vh - 200px);
  }

  [dir="rtl"] .chat-panel {
    left: 16px;
    right: 16px;
  }
}

/* Print styles */
@media print {
  .no-print,
  #lanerm-chat-widget {
    display: none !important;
  }
}
