/* =============================================
   style.css - WhatsApp Scheduler UI
   Design: Dark industrial with green WhatsApp accent
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&family=Sora:wght@300;400;500;600;700&display=swap');

/* ---- Variables ---- */
:root {
  --bg:          #0a0d0f;
  --surface:     #111417;
  --surface2:    #1a1f24;
  --surface3:    #22282f;
  --border:      #2a3038;
  --border2:     #3a424e;
  --green:       #25d366;
  --green-dim:   #1a9e4a;
  --green-glow:  rgba(37,211,102,0.15);
  --red:         #ff4444;
  --yellow:      #f5a623;
  --blue:        #4a9eff;
  --text:        #e8edf2;
  --text-dim:    #8a9bac;
  --text-muted:  #4a5568;
  --radius:      10px;
  --radius-lg:   16px;
  --shadow:      0 4px 24px rgba(0,0,0,0.5);
  --font:        'Sora', sans-serif;
  --mono:        'JetBrains Mono', monospace;
  --transition:  0.2s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 15px;
}
a { color: var(--green); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }
button, input, select, textarea { font-family: var(--font); }
img { max-width: 100%; }

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

/* ---- Sidebar ---- */
.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 28px 24px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--green);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.sidebar-logo h1 { font-size: 16px; font-weight: 600; line-height: 1.3; color: var(--text); }
.sidebar-logo span { font-size: 11px; color: var(--text-muted); font-family: var(--mono); }

.sidebar-nav { flex: 1; padding: 16px 12px; }
.nav-section { margin-bottom: 24px; }
.nav-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--text-muted);
  padding: 0 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: 14px; font-weight: 500;
  transition: all var(--transition); cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active {
  background: var(--surface2);
  color: var(--text);
}
.nav-item.active { color: var(--green); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--green);
  border-radius: 0 3px 3px 0;
}
.nav-item { position: relative; }
.nav-icon { font-size: 18px; width: 20px; text-align: center; }

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--green-dim);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info span { font-size: 11px; color: var(--text-muted); }
.user-actions a { color: var(--text-muted); font-size: 18px; }

/* ---- Main Content ---- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title h2 { font-size: 20px; font-weight: 600; }
.topbar-title p { font-size: 12px; color: var(--text-muted); }

.content { padding: 32px; flex: 1; }

/* ---- Cards / Stats ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  display: flex; align-items: center; gap: 16px;
  transition: border-color var(--transition);
}
.stat-card:hover { border-color: var(--border2); }
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.stat-icon.green  { background: var(--green-glow); }
.stat-icon.yellow { background: rgba(245,166,35,.15); }
.stat-icon.red    { background: rgba(255,68,68,.15); }
.stat-icon.blue   { background: rgba(74,158,255,.15); }
.stat-value { font-size: 28px; font-weight: 700; font-family: var(--mono); line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---- Table ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--surface2);
  padding: 12px 16px;
  text-align: left; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted); border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 14px 16px; font-size: 14px; vertical-align: middle; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-pending   { background: rgba(245,166,35,.15); color: var(--yellow); }
.badge-sending   { background: rgba(74,158,255,.15); color: var(--blue); }
.badge-sent      { background: var(--green-glow); color: var(--green); }
.badge-failed    { background: rgba(255,68,68,.15); color: var(--red); }
.badge-cancelled { background: rgba(100,100,100,.15); color: var(--text-muted); }
.badge-admin     { background: rgba(74,158,255,.2); color: var(--blue); }
.badge-user      { background: var(--surface3); color: var(--text-dim); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: none; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--green); color: #000; }
.btn-primary:hover { background: #1ebe5a; }
.btn-secondary { background: var(--surface3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--border2); background: var(--surface2); }
.btn-danger { background: rgba(255,68,68,.15); color: var(--red); border: 1px solid rgba(255,68,68,.2); }
.btn-danger:hover { background: rgba(255,68,68,.25); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; }

/* ---- Forms ---- */
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 640px;
}
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-dim); margin-bottom: 8px; }
.form-control {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 14px;
  font-size: 14px;
  transition: border-color var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-glow); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 120px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-check { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.form-check input[type=checkbox], .form-check input[type=radio] { accent-color: var(--green); width: 16px; height: 16px; cursor: pointer; }

/* ---- Alert / Flash ---- */
.alert {
  padding: 14px 18px; border-radius: 8px;
  font-size: 14px; margin-bottom: 24px;
  display: flex; align-items: center; gap: 10px;
}
.alert-success { background: var(--green-glow); border: 1px solid rgba(37,211,102,.3); color: var(--green); }
.alert-error   { background: rgba(255,68,68,.1); border: 1px solid rgba(255,68,68,.3); color: var(--red); }
.alert-info    { background: rgba(74,158,255,.1); border: 1px solid rgba(74,158,255,.3); color: var(--blue); }
.alert-warning { background: rgba(245,166,35,.1); border: 1px solid rgba(245,166,35,.3); color: var(--yellow); }

/* ---- Login Page ---- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(37,211,102,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(74,158,255,0.04) 0%, transparent 40%);
}
.login-box {
  width: 100%; max-width: 420px;
  padding: 20px;
}
.login-logo {
  text-align: center; margin-bottom: 40px;
}
.login-logo .logo-circle {
  width: 64px; height: 64px;
  background: var(--green);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 30px;
  margin: 0 auto 16px;
  box-shadow: 0 0 40px var(--green-glow);
}
.login-logo h1 { font-size: 24px; font-weight: 700; }
.login-logo p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
}
.login-card h2 { font-size: 18px; margin-bottom: 24px; font-weight: 600; }

/* ---- Status indicator ---- */
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.offline { background: var(--red); }

/* ---- Connection Card ---- */
.conn-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex; align-items: center; gap: 20px;
  margin-bottom: 24px;
}
.conn-icon { font-size: 36px; }
.conn-info { flex: 1; }
.conn-info strong { font-size: 16px; display: block; }
.conn-info span { color: var(--text-muted); font-size: 13px; }
.conn-status { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; }

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

/* ---- Recipient tags ---- */
.tag-input-wrap {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex; flex-wrap: wrap; gap: 6px;
  transition: border-color var(--transition);
  min-height: 48px;
  cursor: text;
}
.tag-input-wrap:focus-within { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-glow); }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 13px; font-family: var(--mono);
}
.tag .remove { cursor: pointer; opacity: 0.6; font-size: 16px; line-height: 1; }
.tag .remove:hover { opacity: 1; color: var(--red); }
#tag-input { background: none; border: none; outline: none; color: var(--text); font-size: 13px; min-width: 140px; flex: 1; }

/* ---- Datetime ---- */
input[type=datetime-local].form-control::-webkit-calendar-picker-indicator { filter: invert(0.7); cursor: pointer; }

/* ---- Pagination ---- */
.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: center; }
.pagination a {
  padding: 6px 12px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 13px;
  transition: all var(--transition);
}
.pagination a:hover, .pagination a.active { background: var(--green); color: #000; border-color: var(--green); }

/* ---- Utilities ---- */
.text-muted { color: var(--text-muted); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-mono   { font-family: var(--mono); }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-16 { gap: 16px; }
.mb-0 { margin-bottom: 0; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8  { margin-top: 8px; }
.w-full { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }
.actions-cell { display: flex; gap: 6px; align-items: center; }
.section-title { font-size: 18px; font-weight: 600; margin-bottom: 20px; }

/* ---- Mobile ---- */
.hamburger { display: none; cursor: pointer; background: none; border: none; color: var(--text); font-size: 22px; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -280px; top: 0; z-index: 200; height: 100vh; transition: left 0.3s; }
  .sidebar.open { left: 0; }
  .main { width: 100%; }
  .hamburger { display: block; }
  .content { padding: 20px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-card { padding: 20px; }
  .topbar { padding: 0 16px; }
}

/* ---- Overlay ---- */
.overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 150; }
.overlay.show { display: block; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
