/* WA Bot Platform - SmartHome Inspired Theme */
@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --wa-primary: #25D366;
  --wa-primary-dark: #128C7E;
  --wa-primary-light: #dcfce7;
  --wa-accent: #075E54;
  --wa-sidebar-start: #0f172a;
  --wa-sidebar-end: #1e293b;
  --wa-bg: #f1f5f9;
  --wa-card: #ffffff;
  --wa-card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --wa-card-shadow-hover: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --wa-text: #1e293b;
  --wa-text-muted: #64748b;
  --wa-border: #e2e8f0;
  --wa-radius: 16px;
  --wa-radius-sm: 10px;
  --wa-radius-lg: 24px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Nunito Sans', sans-serif; background: var(--wa-bg); color: var(--wa-text); min-height: 100vh; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--wa-sidebar-start), var(--wa-sidebar-end));
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  border-radius: 0 var(--wa-radius) var(--wa-radius) 0;
  overflow: hidden;
}

.sidebar-brand {
  padding: 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  background: var(--wa-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 800;
}

.sidebar-brand .brand-text {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Nunito', sans-serif;
}

.sidebar-brand .brand-text small {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.6;
}

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-section { margin-bottom: 8px; }
.nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.4;
  padding: 8px 12px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--wa-radius-sm);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
  margin-bottom: 2px;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-item.active { background: rgba(37,211,102,0.15); color: var(--wa-primary); }
.nav-item .nav-icon { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  opacity: 0.4;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px 32px;
  min-height: 100vh;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-family: 'Nunito', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--wa-text);
}

.page-subtitle {
  font-size: 14px;
  color: var(--wa-text-muted);
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--wa-card);
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-card-shadow);
  padding: 24px;
  transition: box-shadow 0.2s ease;
}

.card:hover { box-shadow: var(--wa-card-shadow-hover); }
.card-header { font-size: 16px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* Stats Grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 28px; }

.stat-card {
  background: var(--wa-card);
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-card-shadow);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s ease;
}

.stat-card:hover { box-shadow: var(--wa-card-shadow-hover); transform: translateY(-2px); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.purple { background: #f3e8ff; color: #9333ea; }

.stat-info .stat-value { font-size: 28px; font-weight: 800; font-family: 'Nunito', sans-serif; }
.stat-info .stat-label { font-size: 13px; color: var(--wa-text-muted); font-weight: 600; }

/* Project Cards */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 20px; }

.project-card {
  background: var(--wa-card);
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-card-shadow);
  padding: 24px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.project-card:hover { box-shadow: var(--wa-card-shadow-hover); transform: translateY(-2px); }

.project-card .status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}

.status-dot.connected { background: #22c55e; box-shadow: 0 0 8px rgba(34,197,94,0.4); }
.status-dot.connecting { background: #f59e0b; animation: pulse 1.5s infinite; }
.status-dot.disconnected { background: #94a3b8; }
.status-dot.error { background: #ef4444; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.project-title { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.project-phone { font-size: 13px; color: var(--wa-text-muted); margin-bottom: 12px; }
.project-meta { display: flex; gap: 16px; font-size: 12px; color: var(--wa-text-muted); }
.project-meta span { display: flex; align-items: center; gap: 4px; }
.project-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Buttons */
.btn {
  padding: 8px 18px;
  border-radius: var(--wa-radius-sm);
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
  text-decoration: none;
  font-family: 'Nunito Sans', sans-serif;
}

.btn-primary { background: var(--wa-primary); color: white; }
.btn-primary:hover { background: #1fb855; }
.btn-secondary { background: #f1f5f9; color: var(--wa-text); }
.btn-secondary:hover { background: #e2e8f0; }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* Forms */
.form-group { margin-bottom: 20px; }
.form-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--wa-text); }
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--wa-border);
  border-radius: var(--wa-radius-sm);
  font-size: 14px;
  font-family: 'Nunito Sans', sans-serif;
  transition: border-color 0.15s ease;
  background: white;
}
.form-input:focus { outline: none; border-color: var(--wa-primary); }
.form-input::placeholder { color: #94a3b8; }
select.form-input { appearance: auto; }
textarea.form-input { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--wa-text-muted); margin-top: 4px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: var(--wa-radius-lg);
  padding: 32px;
  max-width: 520px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,0.15);
}

.modal-title { font-size: 20px; font-weight: 800; font-family: 'Nunito', sans-serif; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

/* QR Section */
.qr-container {
  text-align: center;
  padding: 24px;
  background: white;
  border-radius: var(--wa-radius);
  border: 2px dashed var(--wa-border);
}

.qr-container img {
  max-width: 256px;
  border-radius: 12px;
  margin: 12px 0;
}

.qr-status { font-size: 14px; font-weight: 600; margin-top: 12px; }
.qr-status.waiting { color: #f59e0b; }
.qr-status.connected { color: #22c55e; }
.qr-status.error { color: #ef4444; }

/* Message Log */
.log-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.log-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--wa-text-muted);
  border-bottom: 2px solid var(--wa-border);
}
.log-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--wa-border);
}
.log-table tr:hover td { background: #f8fafc; }

/* Badge */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}
.badge-connected { background: #dcfce7; color: #16a34a; }
.badge-connecting { background: #fef3c7; color: #d97706; }
.badge-disconnected { background: #f1f5f9; color: #64748b; }
.badge-error { background: #fee2e2; color: #dc2626; }

/* Top bar (mobile) */
.topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: white;
  border-bottom: 1px solid var(--wa-border);
  z-index: 40;
  align-items: center;
  padding: 0 16px;
}

.hamburger {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
}

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 200; }
.toast {
  background: white;
  border-radius: var(--wa-radius-sm);
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 14px 20px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--wa-primary);
}
.toast.error { border-left-color: #ef4444; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 72px 16px 16px; }
  .topbar { display: flex; }
  .stats-grid { grid-template-columns: 1fr; }
  .projects-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--wa-text-muted); }
.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--wa-text); }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* Detail page layout */
.detail-grid { display: grid; grid-template-columns: 350px 1fr; gap: 24px; }
@media (max-width: 1024px) { .detail-grid { grid-template-columns: 1fr; } }

/* Membership badge */
.membership-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.membership-free { background: #f1f5f9; color: #64748b; }
.membership-pro { background: linear-gradient(135deg, #f59e0b, #ef4444); color: white; }
.membership-enterprise { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; }
