/* ====================================
   NEOBRUTALISM CSS - WA BLAST
   Responsive Mobile & Desktop
   ==================================== */

/* ========== CSS VARIABLES ========== */
:root {
  --bg: #F8F6F1;
  --text: #3D3D50;
  --primary: #E8A0BF;
  --secondary: #9EC5D6;
  --accent: #F5DEB3;
  --success: #B5D8C0;
  --warning: #F0D9A0;
  --danger: #E8A0A0;
  --info: #A5A0D6;
  --gray-100: #F5F3F0;
  --gray-200: #E8E5E0;
  --gray-300: #D4D0CA;
  --gray-500: #9A9590;
  --gray-700: #6A6570;
  --gray-900: #3D3D50;

  --shadow-sm: 2px 2px 0px #C8C5BE;
  --shadow-md: 3px 3px 0px #C8C5BE;
  --shadow-lg: 4px 4px 0px #C8C5BE;
  --shadow-xl: 5px 5px 0px #C8C5BE;

  --border: 2px solid #C8C5BE;
  --radius: 12px;

  --nav-height: 64px;
  --container-padding: 2rem;
  --grid-gap: 1.5rem;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }

/* ========== ICON SIZING ========== */
.icon-xs { width: 14px; height: 14px; }
.icon-sm { width: 18px; height: 18px; }
.icon-md { width: 24px; height: 24px; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 48px; height: 48px; }

/* ========== NAVBAR ========== */
.navbar {
  background: var(--primary);
  border-bottom: none;
  padding: 0 1.5rem;
  height: var(--nav-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand .logo {
  animation: pulse 2s infinite;
  display: flex;
  align-items: center;
}

.nav-brand a {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -1px;
}

.mobile-menu-btn {
  display: none;
  background: white;
  border: var(--border);
  padding: 0.5rem;
  cursor: pointer;
  line-height: 0;
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
}

.mobile-menu-btn:hover {
  box-shadow: none;
  transform: translate(2px, 2px);
}

.mobile-menu-btn .icon-sm { width: 24px; height: 24px; }

.nav-links {
  display: flex;
  gap: 0.75rem;
}

.nav-link {
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  border: var(--border);
  background: white;
  border-radius: 8px;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  background: var(--accent);
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}

/* ========== CONTAINER ========== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--container-padding);
}

/* ========== PAGE HEADER ========== */
.page-header { margin-bottom: 2rem; }

.page-header h1 {
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -2px;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.subtitle {
  color: var(--gray-500);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.breadcrumb {
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--info);
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.breadcrumb a:hover { text-decoration: underline; }

/* ========== CARDS ========== */
.card {
  background: white;
  border: var(--border);
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  border-radius: var(--radius);
  transition: all 0.2s;
}

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

/* ========== STATS GRID ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--grid-gap);
  margin-bottom: 2rem;
}

.stat-card {
  text-align: center;
  border-left: 5px solid var(--card-color);
  background: var(--card-color);
  padding: 1.25rem 1rem;
  border-radius: var(--radius);
}

.stat-icon {
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: center;
}

.stat-icon .icon-xl { width: 36px; height: 36px; }

.stat-value {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-top: 0.25rem;
}

/* ========== SECTION HEADER ========== */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: var(--border);
  gap: 1rem;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.25rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: 2px solid #C8C5BE;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  white-space: nowrap;
}

.btn:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
  filter: brightness(0.97);
}

.btn:active {
  box-shadow: none;
  transform: translateY(0);
}

.btn-primary { background: var(--primary); color: var(--text); }
.btn-secondary { background: white; color: var(--text); }
.btn-accent { background: var(--accent); color: var(--text); }
.btn-success { background: var(--success); color: var(--text); }
.btn-warning { background: var(--warning); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

/* ========== BOT GRID ========== */
.bot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--grid-gap);
  margin-bottom: 2rem;
}

.bot-card { border-top: 4px solid var(--secondary); border-radius: var(--radius); }

.bot-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.bot-avatar {
  background: var(--accent);
  border: var(--border);
  width: 52px;
  height: 52px;
  min-width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.bot-info { flex: 1; min-width: 0; }

.bot-info h3 {
  font-size: 1.1rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-phone {
  color: var(--gray-500);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.status-badge {
  padding: 0.25rem 0.6rem;
  border: 1.5px solid #C8C5BE;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  border-radius: 20px;
}

.status-online { background: var(--success); }
.status-offline { background: #FFE0E0; }

.bot-meta {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px dashed var(--gray-200);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.bot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.inline-form { display: inline; }

/* ========== MESSAGE GRID ========== */
.message-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--grid-gap);
  margin-bottom: 2rem;
}

.message-card {
  border-top: 4px solid var(--info);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
}

.message-image {
  margin: -1.5rem -1.5rem 1rem -1.5rem;
  overflow: hidden;
}

.message-image img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-bottom: var(--border);
}

.message-content { flex: 1; }

.message-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--info);
}

.message-body {
  font-size: 0.9rem;
  color: #444;
  margin-bottom: 0.4rem;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.message-footer {
  font-size: 0.8rem;
  color: var(--gray-500);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.message-cta a {
  color: var(--info);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
}

.message-cta a:hover { text-decoration: underline; }

.message-buttons-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.button-chip {
  background: var(--accent);
  border: 1.5px solid #C8C5BE;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  border-radius: 6px;
}

.message-meta {
  font-size: 0.75rem;
  color: #999;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 2px dashed var(--gray-200);
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.message-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* ========== FORMS ========== */
.form-card { max-width: 700px; }

.form-group { margin-bottom: 1.25rem; }

.form-group label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

.form-input {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  border: 2px solid #D4D0CA;
  background: white;
  border-radius: 8px;
  transition: all 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(232,160,191,0.2);
  background: white;
}

.form-input::placeholder { color: #aaa; }

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231A1A2E' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}

textarea.form-input {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 0.3rem;
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
}

.form-hint code {
  background: var(--gray-100);
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--gray-200);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  word-break: break-all;
  border-radius: 4px;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-group.half { flex: 1; }

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: var(--border);
  flex-wrap: wrap;
}

/* ========== FILE UPLOAD ========== */
.file-upload {
  position: relative;
  border: 2px dashed #D4D0CA;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 10px;
}

.file-upload:hover { background: var(--accent); }

.file-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-label {
  font-weight: 600;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-direction: column;
}

.image-preview {
  max-width: 100%;
  max-height: 200px;
  border: 2px solid var(--gray-200);
  margin-top: 0.75rem;
  border-radius: 8px;
}

.current-image { margin-top: 0.75rem; }

.current-image p {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ========== BUTTON INPUT ROW ========== */
.button-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.button-input-row .form-input { flex: 1; }

.remove-btn { flex-shrink: 0; }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 2.5rem 1.5rem;
}

.empty-icon {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  opacity: 0.5;
}

.empty-state h3 { font-size: 1.3rem; margin-bottom: 0.5rem; }

.empty-state p {
  color: var(--gray-500);
  margin-bottom: 1.25rem;
}

/* ========== QR CONNECT ========== */
.connect-card {
  text-align: center;
  max-width: 600px;
  margin: 0 auto;
}

.qr-container { padding: 1.5rem; }

.qr-loading { padding: 2rem; }

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 1s linear infinite;
}

.qr-image {
  width: 280px;
  height: 280px;
  border: 2px solid var(--gray-200);
  margin: 1rem auto;
  display: block;
  border-radius: 10px;
}

#qrCanvas {
  display: block;
  margin: 1rem auto;
  border-radius: 10px;
  border: 2px solid var(--gray-200);
  max-width: 100%;
  height: auto !important;
}

.qr-wrapper {
  background: white;
  padding: 0.75rem;
  border: 2px solid var(--gray-200);
  display: inline-block;
  margin: 1rem 0;
  border-radius: 12px;
}

.qr-instructions {
  text-align: left;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  padding: 1rem;
  margin-top: 1rem;
  border-radius: 10px;
}

.qr-instructions ol {
  padding-left: 1.5rem;
  margin-top: 0.5rem;
}

.qr-instructions li {
  margin-bottom: 0.3rem;
  line-height: 1.5;
}

.connected-status { padding: 1.5rem; }

.success-icon {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
}

.connect-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* ========== RESULT CARDS ========== */
.result-card {
  margin-bottom: 1.5rem;
  border-radius: var(--radius);
}

.result-card h3 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.success-card {
  border-left: 5px solid var(--success);
  background: #F0F8F2;
}

.error-card {
  border-left: 5px solid var(--danger);
  background: #FDF2F2;
}

.warning-card {
  border-left: 5px solid var(--warning);
  background: #FDF8EE;
}

.warning-icon {
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: center;
}

.result-list { margin-top: 0.75rem; }

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--gray-200);
  font-size: 0.85rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.result-success { background: #EFF8F1; padding: 0.4rem; border-radius: 6px; }
.result-failed { background: #FDF2F2; padding: 0.4rem; border-radius: 6px; }

.inline-warning {
  padding: 0.75rem !important;
  margin-top: 0.5rem;
}

.inline-warning p {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
}

/* ========== MESSAGE PREVIEW ========== */
.message-preview-box {
  border: 1.5px solid var(--gray-200);
  margin-top: 0.75rem;
  background: var(--gray-100);
  border-radius: 10px;
  overflow: hidden;
}

.preview-header {
  background: var(--info);
  color: white;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 8px 8px 0 0;
}

.preview-content { padding: 0.75rem; }
.preview-content h4 { margin-bottom: 0.4rem; }
.preview-content p { margin-bottom: 0.4rem; }

.preview-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

/* ========== TEXT UTILITIES ========== */
.text-green { color: #4A8B5C; font-weight: 600; display: inline-flex; align-items: center; gap: 0.25rem; }
.text-red { color: #B85C5C; font-weight: 600; display: inline-flex; align-items: center; gap: 0.25rem; }
.text-gray { color: var(--gray-500); }

/* ========== FOOTER ========== */
.footer {
  background: var(--gray-700);
  color: #F0EDE8;
  padding: 1.25rem 1.5rem;
  margin-top: 3rem;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.footer-content span {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.footer-content .icon-sm { color: var(--accent); }

/* ========== UTILITIES ========== */
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.25rem; }

/* ========== ANIMATIONS ========== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
   RESPONSIVE - TABLET (max-width: 768px)
   ========================================== */
@media (max-width: 768px) {
  :root {
    --container-padding: 1rem;
    --grid-gap: 1rem;
  }

  /* Navbar */
  .navbar {
    padding: 0 1rem;
    flex-wrap: wrap;
    height: auto;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    gap: 0.5rem;
  }

  .mobile-menu-btn { display: flex; }

  .nav-links {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
  }

  .nav-links.open { display: flex; }

  .nav-link {
    width: 100%;
    justify-content: center;
  }

  /* Stats */
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Bot grid */
  .bot-grid { grid-template-columns: 1fr; }

  /* Message grid */
  .message-grid { grid-template-columns: 1fr; }

  /* Section header */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-header .btn { width: 100%; }

  /* Form row */
  .form-row { flex-direction: column; }

  /* Form actions */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  /* Connect actions */
  .connect-actions { flex-direction: column; }
  .connect-actions .btn { width: 100%; }

  /* Footer */
  .footer-content {
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  /* Cards */
  .card { padding: 1rem; border-radius: 10px; }
  .card:hover { transform: none; }

  /* Bot header */
  .bot-header { flex-wrap: wrap; }
  .status-badge { margin-left: auto; }

  /* Bot actions */
  .bot-actions { flex-direction: column; }
  .bot-actions .btn { width: 100%; border-radius: 8px; }

  /* Message actions */
  .message-actions { flex-direction: column; }
  .message-actions .btn { width: 100%; border-radius: 8px; }

  /* QR */
  .qr-image { width: 240px; height: 240px; border-radius: 10px; }

  /* Result */
  .result-item {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ==========================================
   RESPONSIVE - MOBILE SMALL (max-width: 480px)
   ========================================== */
@media (max-width: 480px) {
  html { font-size: 14px; }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
  }

  .stat-card { padding: 0.75rem 0.5rem; }
  .stat-value { font-size: 2rem; }
  .stat-label { font-size: 0.7rem; }

  .btn {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  .btn-small {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
  }

  .page-header h1 {
    font-size: 1.5rem;
    letter-spacing: -1px;
  }

  .form-input {
    padding: 0.6rem 0.75rem;
    font-size: 0.9rem;
  }

  .file-upload { padding: 1rem; }

  .qr-image { width: 200px; height: 200px; }

  .empty-state { padding: 1.5rem 1rem; }
}

/* ==========================================
   RESPONSIVE - DESKTOP LARGE (min-width: 1200px)
   ========================================== */
@media (min-width: 1200px) {
  .container { max-width: 1200px; }
  .bot-grid { grid-template-columns: repeat(3, 1fr); }
  .message-grid { grid-template-columns: repeat(3, 1fr); }
}
