/* ============================================================
   WA Cloud Manager — Custom CSS
   Stack: Bootstrap 5.3 + Custom Design System
   ============================================================ */

/* ── Fonts & Variables ─────────────────────────────────────── */
:root {
  --wa-green:       #25D366;
  --wa-dark-green:  #128C7E;
  --wa-teal:        #075E54;
  --sidebar-width:  260px;
  --sidebar-bg:     #0f172a;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #25D366;
  --primary-custom: #6366f1;
  --primary-dark:   #4f46e5;
  --body-bg:        #f1f5f9;
  --card-bg:        #ffffff;
  --border-radius:  12px;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:      0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:      0 8px 32px rgba(0,0,0,.12);
  --transition:     all .2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--body-bg);
  color: #1e293b;
  font-size: .875rem;
  line-height: 1.6;
  margin: 0;
}

/* ── Utility ───────────────────────────────────────────────── */
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.text-primary-custom { color: var(--primary-custom) !important; }

/* ── App Wrapper ───────────────────────────────────────────── */
.app-wrapper { min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 1000;
  transition: transform .3s ease;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.logo-icon {
  width: 38px; height: 38px;
  background: var(--wa-green);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(37,211,102,.4);
  flex-shrink: 0;
}

.logo-name { color: #f1f5f9; font-weight: 700; font-size: .95rem; line-height: 1.1; }
.logo-tagline { color: var(--sidebar-text); font-size: .65rem; letter-spacing: .3px; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.06);
  margin: .5rem 0;
}

.sidebar-section-title {
  color: #475569; font-size: .6rem; font-weight: 700;
  letter-spacing: .8px; padding: .5rem 1.25rem .25rem;
  margin: 0; text-transform: uppercase;
}

.sidebar-nav { padding: .25rem .75rem; flex: 1; }

.sidebar-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem .75rem;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .83rem; font-weight: 500;
  transition: var(--transition);
  position: relative;
  margin-bottom: 2px;
}

.sidebar-link:hover {
  color: #f1f5f9;
  background: rgba(255,255,255,.07);
}

.sidebar-link.active {
  background: rgba(37,211,102,.15);
  color: var(--wa-green);
}

.sidebar-link.active i { color: var(--wa-green); }
.sidebar-link i { font-size: 1rem; width: 20px; text-align: center; }

.sidebar-badge {
  margin-left: auto;
  background: var(--wa-green);
  color: white;
  font-size: .55rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  letter-spacing: .5px;
}

/* Subscription usage card */
.sidebar-bottom { padding: .75rem; margin-top: auto; }

.subscription-card {
  background: rgba(255,255,255,.06);
  border-radius: 10px;
  padding: .75rem;
  border: 1px solid rgba(255,255,255,.08);
}

.sub-plan-name { color: #f1f5f9; font-size: .75rem; font-weight: 700; }
.sub-count { color: var(--sidebar-text); font-size: .7rem; }
.sub-label { color: var(--sidebar-text); font-size: .65rem; margin: 0; }

/* ── Mobile Sidebar ────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}

@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main-content { margin-left: 0 !important; }
}

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content { margin-left: var(--sidebar-width); }

/* ── Top Navbar ────────────────────────────────────────────── */
.top-navbar {
  height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid #e2e8f0;
  position: sticky; top: 0; z-index: 100;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
}

.page-breadcrumb h5 { font-size: .95rem; color: #1e293b; }

.user-pill {
  background: #f8fafc; border: 1px solid #e2e8f0;
  border-radius: 50px; padding: .3rem .75rem;
  font-size: .8rem; font-weight: 600;
  transition: var(--transition);
}
.user-pill:hover { background: #f1f5f9; }

.avatar-circle {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary-custom), var(--wa-green));
  border-radius: 50%;
  color: white; font-weight: 700; font-size: .75rem;
  display: flex; align-items: center; justify-content: center;
}

.avatar-circle-sm {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--primary-custom), var(--wa-green));
  border-radius: 50%;
  color: white; font-weight: 700; font-size: .7rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.avatar-lg {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary-custom), var(--wa-green));
  border-radius: 50%;
  color: white; font-weight: 800; font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
}

.btn-icon { border: 1px solid #e2e8f0; background: white; border-radius: 8px; padding: .4rem .5rem; }

/* ── Page Content ──────────────────────────────────────────── */
.page-content { padding: 1.5rem; min-height: calc(100vh - 64px); }

/* ============================================================
   CARDS
   ============================================================ */
.card-custom {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  border: 1px solid #e2e8f0;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-custom-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  background: #fafbfc;
}

.card-custom-body { padding: 1.25rem; }

.card-custom-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid #f1f5f9;
  background: #fafbfc;
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card {
  padding: 1.25rem;
  border-radius: var(--border-radius);
  position: relative; overflow: hidden;
  color: white;
  transition: transform .2s ease, box-shadow .2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

.stat-card-sm { padding: .9rem 1rem; }

.stat-card-blue   { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.stat-card-green  { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-card-red    { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.stat-card-purple { background: linear-gradient(135deg, #a855f7, #7c3aed); }
.stat-card-yellow { background: linear-gradient(135deg, #f59e0b, #d97706); }

.stat-icon { font-size: 1.5rem; opacity: .9; margin-bottom: .3rem; }
.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-card-sm .stat-value { font-size: 1.3rem; }
.stat-label { font-size: .75rem; opacity: .85; margin-top: .2rem; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn-wa {
  background: linear-gradient(135deg, var(--wa-green), var(--wa-dark-green));
  color: white; border: none; font-weight: 600;
  border-radius: 8px;
  transition: var(--transition);
}
.btn-wa:hover {
  background: linear-gradient(135deg, #20ba5a, #0f7a6d);
  color: white; transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,211,102,.35);
}

.btn-xs {
  padding: .2rem .45rem; font-size: .72rem; border-radius: 6px;
}

/* ============================================================
   TABLE STYLES
   ============================================================ */
.table th {
  background: #f8fafc; font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: #64748b;
  border-bottom: 2px solid #e2e8f0;
}

.table td { vertical-align: middle; color: #334155; border-color: #f1f5f9; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* ============================================================
   CONNECTION CARDS
   ============================================================ */
.connection-card {
  background: var(--card-bg); border-radius: var(--border-radius);
  border: 1px solid #e2e8f0; box-shadow: var(--shadow-sm);
  transition: var(--transition); overflow: hidden;
}
.connection-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.connection-card.inactive { opacity: .6; }

.connection-card-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 1rem 1.25rem; border-bottom: 1px solid #f1f5f9; background: #fafbfc;
}

.conn-icon {
  width: 36px; height: 36px; background: rgba(37,211,102,.15);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--wa-green); font-size: 1.1rem;
}

.connection-card-body { padding: 1rem 1.25rem; }
.connection-card-footer {
  padding: .75rem 1.25rem; display: flex; gap: .4rem;
  border-top: 1px solid #f1f5f9; background: #fafbfc;
}

.field-row { display: flex; justify-content: space-between; align-items: center; padding: .2rem 0; font-size: .8rem; }
.field-label { color: #64748b; }
.field-value { font-family: 'Courier New', monospace; font-size: .78rem; }

/* ============================================================
   TEMPLATE CARDS
   ============================================================ */
.template-card {
  background: var(--card-bg); border: 1px solid #e2e8f0;
  border-radius: var(--border-radius); box-shadow: var(--shadow-sm);
  transition: var(--transition); overflow: hidden;
}
.template-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.template-card-header {
  padding: .9rem 1rem; background: #fafbfc;
  border-bottom: 1px solid #f1f5f9;
  display: flex; justify-content: space-between; align-items: flex-start;
}

.template-header-preview {
  padding: .5rem 1rem; background: #e8f5e9; font-size: .78rem; color: #2e7d32;
  border-bottom: 1px solid #c8e6c9;
}

.template-body-preview {
  padding: .75rem 1rem; font-size: .8rem; color: #374151;
  line-height: 1.5; min-height: 60px;
}

.template-footer-preview {
  padding: .4rem 1rem; font-size: .72rem; color: #6b7280;
  border-top: 1px solid #f1f5f9; background: #fafbfc;
  font-style: italic;
}

.template-card-footer {
  padding: .6rem 1rem; display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid #f1f5f9; background: #f8fafc;
}

/* ============================================================
   WHATSAPP PREVIEW BUBBLE
   ============================================================ */
.wa-preview-phone {
  background: #e5ddd5 url("data:image/svg+xml,%3Csvg width='30' height='30' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0h30v30H0z' fill='%23e5ddd5'/%3E%3C/svg%3E");
  border-radius: 12px; padding: 1rem; min-height: 120px;
}

.wa-preview-header {
  background: linear-gradient(135deg, var(--wa-teal), var(--wa-dark-green));
  color: white; font-size: .8rem; font-weight: 600;
  padding: .5rem .75rem; border-radius: 8px 8px 0 0; margin-bottom: .5rem;
}

.wa-preview-bubble {
  background: white; border-radius: 0 8px 8px 8px;
  padding: .75rem; box-shadow: 0 1px 4px rgba(0,0,0,.15);
  max-width: 100%;
}

.wa-preview-body { font-size: .82rem; color: #111; line-height: 1.5; }

.wa-preview-footer {
  font-size: .72rem; color: #667781; margin-top: .4rem;
  border-top: 1px solid #f0f0f0; padding-top: .3rem; font-style: italic;
}

.wa-preview-time {
  text-align: right; font-size: .65rem; color: #667781; margin-top: .25rem;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-body { background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%); min-height: 100vh; }

.auth-wrapper {
  display: flex; min-height: 100vh;
}

.auth-brand-panel {
  flex: 1; padding: 3rem;
  display: flex; flex-direction: column; justify-content: center;
  position: relative;
}

.brand-icon {
  width: 64px; height: 64px;
  background: var(--wa-green);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: white;
  box-shadow: 0 8px 32px rgba(37,211,102,.4);
}

.brand-icon-sm {
  width: 36px; height: 36px;
  background: var(--wa-green);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: white;
}

.brand-title { color: white; font-size: 2.2rem; font-weight: 800; line-height: 1.1; }
.brand-subtitle { color: #94a3b8; font-size: .95rem; margin-top: .75rem; max-width: 380px; }

.brand-features { display: flex; flex-direction: column; gap: .6rem; }
.feature-item { display: flex; align-items: center; gap: .6rem; color: #94a3b8; font-size: .88rem; }
.feature-item i { color: var(--wa-green); font-size: 1rem; }

.auth-form-panel {
  width: 440px; max-width: 100%;
  background: white;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  min-height: 100vh;
}

.auth-form-box { width: 100%; max-width: 380px; }
.auth-form-title { font-size: 1.6rem; font-weight: 800; color: #0f172a; }
.auth-form-subtitle { color: #64748b; margin-bottom: 1.5rem; }

.btn-wa.w-100 { padding: .75rem; font-size: .95rem; }

/* ============================================================
   STATUS DOT
   ============================================================ */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.status-dot.active  { background: var(--wa-green); box-shadow: 0 0 6px rgba(37,211,102,.6); }
.status-dot.inactive { background: #94a3b8; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  background: var(--card-bg); border-radius: var(--border-radius);
  border: 2px dashed #e2e8f0;
}

.empty-state-icon {
  width: 72px; height: 72px; background: #f1f5f9;
  border-radius: 50%; margin: 0 auto 1rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: #94a3b8;
}

/* ============================================================
   API RESPONSE PRE
   ============================================================ */
.api-response-pre {
  background: #0f172a; color: #a5f3fc; border-radius: 8px;
  padding: .75rem; font-size: .72rem; max-height: 200px; overflow-y: auto;
  font-family: 'Courier New', monospace;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container-custom {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}

.app-toast {
  min-width: 280px; max-width: 380px;
  padding: .85rem 1.25rem;
  border-radius: 10px; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .6rem;
  font-size: .82rem; font-weight: 500; color: white;
  animation: slideInRight .25s ease;
}
.app-toast.success { background: #16a34a; }
.app-toast.danger  { background: #dc2626; }
.app-toast.warning { background: #d97706; }
.app-toast.info    { background: var(--primary-custom); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ============================================================
   PROGRESS BAR CUSTOM
   ============================================================ */
.progress { border-radius: 99px; background: #e2e8f0; }
.progress-bar { border-radius: 99px; }

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown-menu { border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: var(--shadow-md); }
.dropdown-item { font-size: .82rem; padding: .5rem 1rem; border-radius: 6px; margin: 0 .25rem; }
.dropdown-item:hover { background: #f1f5f9; }

/* ============================================================
   TOGGLE PASSWORD
   ============================================================ */
.toggle-password { border-left: 0 !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991px) {
  .main-content { margin-left: 0; }
  .auth-form-panel { width: 100%; min-height: auto; }
  .auth-wrapper { flex-direction: column; }
}

@media (max-width: 576px) {
  .page-content { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
}
