/* ============================================================================
   LÓGIX ORÇAMENTO RÁPIDO — DESIGN SYSTEM (DARK MODE PREMIUM)
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* Core Palette */
  --bg-primary: #0B0F1A;
  --bg-secondary: #111827;
  --bg-tertiary: #1E293B;
  --bg-card: rgba(30, 41, 59, 0.6);
  --bg-glass: rgba(17, 24, 39, 0.85);

  /* Accent Colors */
  --accent-copper: #C2410C;
  --accent-copper-light: #EA580C;
  --accent-copper-glow: rgba(194, 65, 12, 0.25);
  --accent-blue: #0284C7;
  --accent-green: #059669;
  --accent-amber: #D97706;

  /* Text */
  --text-primary: #F1F5F9;
  --text-secondary: #94A3B8;
  --text-tertiary: #64748B;
  --text-inverse: #0F172A;

  /* Borders */
  --border-primary: rgba(148, 163, 184, 0.15);
  --border-accent: rgba(194, 65, 12, 0.4);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px rgba(194, 65, 12, 0.15);

  /* Spacing & Sizing */
  --header-height: 64px;
  --input-height: 64px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== APP LAYOUT ===== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

/* ===== HEADER ===== */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-primary);
  z-index: 100;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid var(--accent-copper);
  box-shadow: var(--shadow-glow);
}

.header-info h1 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.header-info p {
  font-size: 11px;
  color: var(--accent-copper-light);
  font-weight: 600;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--accent-green);
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
}

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-header {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  color: var(--text-secondary);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-header:hover {
  background: var(--accent-copper);
  color: #FFF;
  border-color: var(--accent-copper);
  box-shadow: var(--shadow-glow);
}

.btn-header.btn-pdf {
  background: var(--accent-copper);
  color: #FFF;
  border-color: var(--accent-copper);
}

.btn-header.btn-pdf:hover {
  background: var(--accent-copper-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.btn-header.btn-pdf:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* ===== CHAT AREA ===== */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-area::-webkit-scrollbar {
  width: 6px;
}

.chat-area::-webkit-scrollbar-track {
  background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 3px;
}

/* ===== CHAT MESSAGES ===== */
.message {
  display: flex;
  gap: 10px;
  max-width: 85%;
  animation: msg-in 0.35s var(--transition-normal) forwards;
  opacity: 0;
  transform: translateY(12px);
}

@keyframes msg-in {
  to { opacity: 1; transform: translateY(0); }
}

.message.agent {
  align-self: flex-start;
}

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 800;
}

.message.agent .msg-avatar {
  background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-light));
  color: #FFF;
  box-shadow: 0 2px 10px rgba(194, 65, 12, 0.3);
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, var(--accent-blue), #0EA5E9);
  color: #FFF;
}

.msg-content {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  line-height: 1.65;
  position: relative;
}

.message.agent .msg-content {
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  border-top-left-radius: 4px;
}

.message.user .msg-content {
  background: linear-gradient(135deg, var(--accent-copper), #B91C1C);
  color: #FFF;
  border-top-right-radius: 4px;
  border: none;
}

.msg-time {
  font-size: 10px;
  color: var(--text-tertiary);
  margin-top: 6px;
  display: block;
}

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

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  max-width: 85%;
  animation: msg-in 0.3s ease forwards;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  border-top-left-radius: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: typing-bounce 1.4s infinite;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ===== FILE PREVIEWS IN CHAT ===== */
.msg-files {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.file-thumb {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 2px solid rgba(255,255,255,0.2);
  cursor: pointer;
  transition: var(--transition-fast);
}

.file-thumb:hover {
  transform: scale(1.05);
  border-color: var(--accent-copper);
}

.file-doc {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
}

/* ===== QUICK ACTIONS (CHIPS) ===== */
.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  padding: 8px 16px;
  background: rgba(194, 65, 12, 0.12);
  border: 1px solid rgba(194, 65, 12, 0.3);
  border-radius: var(--radius-full);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent-copper-light);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.chip:hover {
  background: var(--accent-copper);
  color: #FFF;
  border-color: var(--accent-copper);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(194, 65, 12, 0.3);
}

/* ===== ORÇAMENTO PREVIEW CARD ===== */
.orcamento-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 12px;
}

.orcamento-card h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-copper-light);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.orcamento-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.orcamento-table th {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-weight: 700;
  text-align: left;
  padding: 8px 10px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.orcamento-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-primary);
}

.orcamento-table tr:last-child td {
  border-bottom: none;
}

.orcamento-table .total-row {
  background: rgba(194, 65, 12, 0.1);
  font-weight: 800;
  color: var(--accent-copper-light);
}

/* ===== INPUT AREA ===== */
.input-area {
  padding: 12px 20px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-primary);
  flex-shrink: 0;
  z-index: 100;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 6px;
  transition: var(--transition-fast);
}

.input-wrapper:focus-within {
  border-color: var(--accent-copper);
  box-shadow: 0 0 0 3px var(--accent-copper-glow);
}

.input-wrapper textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  resize: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.5;
}

.input-wrapper textarea::placeholder {
  color: var(--text-tertiary);
}

.btn-attach {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-attach:hover {
  color: var(--accent-copper-light);
  background: rgba(194, 65, 12, 0.1);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--accent-copper);
  border: none;
  color: #FFF;
  font-size: 16px;
  cursor: pointer;
  transition: var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-send:hover {
  background: var(--accent-copper-light);
  transform: scale(1.05);
}

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

/* ===== FILE PREVIEW BAR (above input) ===== */
.file-preview-bar {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 0;
}

.file-preview-bar.active {
  display: flex;
}

.file-preview-item {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--border-primary);
}

.file-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-preview-item .file-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  color: var(--text-tertiary);
  font-size: 22px;
}

.file-preview-item .remove-file {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  border: none;
  color: #FFF;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== CONFIG MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

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

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: 30px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.modal-box h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.modal-box p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.modal-box label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-box input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', monospace;
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}

.modal-box input:focus {
  border-color: var(--accent-copper);
  box-shadow: 0 0 0 3px var(--accent-copper-glow);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.btn-modal {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
  border: 1px solid var(--border-primary);
}

.btn-modal.primary {
  background: var(--accent-copper);
  color: #FFF;
  border-color: var(--accent-copper);
}

.btn-modal.primary:hover {
  background: var(--accent-copper-light);
}

.btn-modal.secondary {
  background: transparent;
  color: var(--text-secondary);
}

/* ===== LIGHTBOX ===== */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 2000;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 90%;
  max-height: 90%;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-left: 4px solid var(--accent-green);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.3s ease forwards, toast-out 0.3s ease 3s forwards;
}

.toast.error {
  border-left-color: #EF4444;
}

.toast.warning {
  border-left-color: var(--accent-amber);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(-10px); }
}

/* ===== WELCOME SCREEN ===== */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 30px;
  gap: 16px;
  animation: fade-in 0.6s ease;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.welcome-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-copper), var(--accent-copper-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #FFF;
  box-shadow: 0 8px 30px rgba(194, 65, 12, 0.35);
}

.welcome-screen h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.welcome-screen p {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 400px;
  line-height: 1.6;
}

.welcome-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}

.welcome-chip {
  padding: 12px 22px;
  background: var(--bg-card);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: left;
  max-width: 200px;
}

.welcome-chip:hover {
  border-color: var(--accent-copper);
  background: rgba(194, 65, 12, 0.08);
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.welcome-chip i {
  font-size: 20px;
  color: var(--accent-copper-light);
  display: block;
  margin-bottom: 6px;
}

.welcome-chip strong {
  font-size: 13px;
  color: var(--text-primary);
  display: block;
}

.welcome-chip span {
  font-size: 11px;
  color: var(--text-tertiary);
}

/* ===== MARKDOWN IN MESSAGES ===== */
.msg-content strong {
  font-weight: 700;
}

.msg-content ul, .msg-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.msg-content li {
  margin-bottom: 3px;
}

.msg-content code {
  background: rgba(0,0,0,0.3);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .app-container {
    max-width: 100%;
  }

  .app-header {
    padding: 0 12px;
  }

  .header-info h1 {
    font-size: 13px;
  }

  .header-actions .btn-text {
    display: none;
  }

  .message {
    max-width: 92%;
  }

  .chat-area {
    padding: 14px;
  }

  .input-area {
    padding: 10px 12px;
  }

  .welcome-chips {
    flex-direction: column;
    align-items: center;
  }
  
  .welcome-chip {
    max-width: 100%;
    width: 100%;
  }
}
