/* ================================================
   AQUECEDOR PRO – Folha de estilos
   ================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --green: #25D366;
  --green-d: #128C7E;
  --green-light: #F0FDF4;
  --green-glow: rgba(37,211,102,0.15);
  --sidebar: 240px;
  --topbar: 60px;
  --bg: #F4F6F9;
  --surface: #FFFFFF;
  --border: #E8ECF0;
  --text: #1A1D23;
  --text-2: #64748B;
  --text-3: #94A3B8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }

/* ── LOGIN ──────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0A0F1E 0%, #0D1B2A 40%, #0A2818 100%);
  position: relative; overflow: hidden;
}
.login-page::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 50%, rgba(37,211,102,.08) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 20%, rgba(18,140,126,.06) 0%, transparent 50%);
}
.login-box {
  background: rgba(255,255,255,.97); border-radius: 20px; padding: 44px 40px;
  width: 400px; box-shadow: 0 24px 80px rgba(0,0,0,.35); position: relative; z-index: 1;
  border: 1px solid rgba(255,255,255,.2);
}
.login-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 36px; }
.logo-icon { font-size: 42px; line-height: 1; }
.login-brand { font-size: 24px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.login-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; font-weight: 500; }

/* ── APP LAYOUT ─────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }
#sidebar { width: var(--sidebar); background: #0B1220; display: flex; flex-direction: column; flex-shrink: 0; overflow-y: auto; border-right: 1px solid rgba(255,255,255,.06); }
#main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#content { flex: 1; overflow-y: auto; padding: 24px; }

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 22px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.logo-icon-sm { font-size: 26px; }
.brand-name { font-size: 15px; font-weight: 800; color: #F1F5F9; letter-spacing: -.3px; }
.brand-version { font-size: 10px; color: #475569; font-weight: 500; }

.user-badge { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,.07); }
.user-avatar { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, var(--green), var(--green-d)); color: white; font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #F1F5F9; }
.user-role { font-size: 11px; color: #64748B; margin-top: 1px; }

nav { padding: 10px 10px; flex: 1; }
.nav-group { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: #334155; padding: 14px 8px 5px; font-weight: 700; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer; color: #94A3B8; font-size: 13px; font-weight: 500; text-decoration: none; margin-bottom: 2px; transition: all .15s; position: relative; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #E2E8F0; }
.nav-item.active { background: var(--green-glow); color: #4ADE80; border: 1px solid rgba(37,211,102,.2); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--green); color: white; font-size: 10px; padding: 2px 7px; border-radius: 20px; font-weight: 700; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid rgba(255,255,255,.07); }

/* ── TOPBAR ──────────────────────────────────── */
#topbar { height: var(--topbar); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 24px; gap: 12px; box-shadow: var(--shadow); }
#topbar h1 { font-size: 17px; font-weight: 700; flex: 1; letter-spacing: -.3px; }
#topbar-actions { display: flex; gap: 8px; }

/* ── BUTTONS ─────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: all .15s; text-decoration: none; font-family: inherit; }
.btn:hover { background: var(--bg); border-color: #CBD5E1; }
.btn-primary { background: var(--green); color: white; border-color: var(--green-d); box-shadow: 0 2px 8px rgba(37,211,102,.3); }
.btn-primary:hover { background: var(--green-d); box-shadow: 0 4px 12px rgba(37,211,102,.4); }
.btn-danger { background: #FEF2F2; color: #DC2626; border-color: #FECACA; }
.btn-danger:hover { background: #FEE2E2; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 13px; font-size: 14px; }
.btn svg { width: 14px; height: 14px; }

/* ── CARDS ───────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.card-header h2 { font-size: 14px; font-weight: 700; flex: 1; letter-spacing: -.2px; }
.card-body { padding: 20px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.stat::after { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: linear-gradient(90deg, var(--green), var(--green-d)); border-radius: var(--radius) var(--radius) 0 0; }
.stat .label { font-size: 12px; color: var(--text-2); margin-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -1px; }
.stat .trend { font-size: 12px; margin-top: 4px; font-weight: 500; }
.stat .trend.up { color: #16A34A; }
.stat .trend.down { color: #DC2626; }

/* ── TABLES ──────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 16px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); font-weight: 700; border-bottom: 1px solid var(--border); background: #FAFBFC; white-space: nowrap; }
td { padding: 13px 16px; border-bottom: 1px solid #F1F5F9; color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #FAFBFF; }

/* ── BADGES ──────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-green { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.badge-red { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.badge-amber { background: #FFFBEB; color: #B45309; border: 1px solid #FDE68A; }
.badge-blue { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }
.badge-purple { background: #F5F3FF; color: #6D28D9; border: 1px solid #DDD6FE; }
.badge-gray { background: #F8FAFC; color: #64748B; border: 1px solid #E2E8F0; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; flex-shrink: 0; }

/* ── FORMS ───────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 13px; font-family: inherit;
  transition: all .15s; outline: none; font-weight: 500;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(37,211,102,.12);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-full { grid-column: 1 / -1; }

/* ── ALERTS ──────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; margin-bottom: 14px; }
.alert-danger { background: #FEF2F2; color: #DC2626; border: 1px solid #FECACA; }
.alert-success { background: #F0FDF4; color: #15803D; border: 1px solid #BBF7D0; }
.alert-info { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }

/* ── MODAL ───────────────────────────────────── */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,18,30,.6); backdrop-filter: blur(4px); z-index: 1000; align-items: center; justify-content: center; }
#modal-overlay.open { display: flex; }
#modal { background: var(--surface); border-radius: 16px; width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,.25); border: 1px solid var(--border); }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; }
.modal-header h3 { font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -.3px; }
.modal-close { background: #F1F5F9; border: none; cursor: pointer; font-size: 16px; color: var(--text-2); width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border-radius: 8px; transition: all .15s; }
.modal-close:hover { background: #E2E8F0; color: var(--text); }
#modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── TOAST ───────────────────────────────────── */
#toast { position: fixed; bottom: 24px; right: 24px; background: #1E293B; color: white; padding: 13px 20px; border-radius: 12px; font-size: 13px; font-weight: 600; z-index: 9999; opacity: 0; transform: translateY(10px); transition: all .3s cubic-bezier(.34,1.56,.64,1); pointer-events: none; max-width: 320px; box-shadow: 0 8px 30px rgba(0,0,0,.2); border-left: 4px solid var(--green); }
#toast.show { opacity: 1; transform: translateY(0); }

/* ── CONNECTIONS GRID ────────────────────────── */
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.conn-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; position: relative; box-shadow: var(--shadow); transition: box-shadow .2s; }
.conn-card:hover { box-shadow: var(--shadow-md); }
.conn-card .conn-alias { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.conn-card .conn-phone { font-size: 12px; color: var(--text-2); margin-bottom: 12px; font-weight: 500; }
.conn-card .conn-qr { background: var(--bg); border: 1.5px dashed var(--border); border-radius: var(--radius-sm); padding: 14px; text-align: center; margin-bottom: 12px; }
.conn-card .conn-qr img { max-width: 130px; max-height: 130px; border-radius: 6px; }
.conn-card .conn-qr-text { font-size: 11px; color: var(--text-2); margin-top: 8px; font-weight: 500; line-height: 1.4; }
.conn-card .conn-actions { display: flex; gap: 6px; }
.conn-card .conn-actions .btn { flex: 1; justify-content: center; }
.status-pill { position: absolute; top: 16px; right: 16px; }

/* ── SEQUENCE BUILDER ────────────────────────── */
.builder-wrap { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.steps-list { border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.step-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #F1F5F9; background: var(--surface); }
.step-item:last-child { border-bottom: none; }
.step-num { width: 28px; height: 28px; border-radius: 8px; background: var(--bg); border: 1.5px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; flex-shrink: 0; color: var(--text-2); }
.step-info { flex: 1; }
.step-label { font-size: 11px; color: var(--text-2); margin-bottom: 2px; font-weight: 600; }
.step-content { font-size: 13px; font-weight: 600; }
.step-del { background: none; border: none; cursor: pointer; color: var(--text-3); font-size: 16px; padding: 4px; border-radius: 6px; transition: all .15s; }
.step-del:hover { color: #DC2626; background: #FEF2F2; }
.add-step-btn { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 13px; border: 1.5px dashed var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--text-2); transition: all .15s; background: none; width: 100%; margin-top: 8px; font-family: inherit; }
.add-step-btn:hover { border-color: var(--green); color: var(--green); background: var(--green-light); }

/* ── PLANS GRID ──────────────────────────────── */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.plan-card { background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 22px; position: relative; box-shadow: var(--shadow); transition: all .2s; }
.plan-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.plan-card.featured { border: 2px solid var(--green); box-shadow: 0 4px 20px rgba(37,211,102,.15); }
.plan-featured-badge { position: absolute; top: -1px; right: 18px; background: var(--green); color: white; font-size: 10px; font-weight: 800; padding: 4px 12px; border-radius: 0 0 10px 10px; letter-spacing: .05em; }
.plan-name { font-size: 17px; font-weight: 800; margin-bottom: 4px; letter-spacing: -.3px; }
.plan-price { font-size: 30px; font-weight: 800; color: var(--green-d); margin-bottom: 16px; letter-spacing: -1px; }
.plan-price small { font-size: 14px; font-weight: 500; color: var(--text-2); }
.plan-features { list-style: none; margin-bottom: 18px; display: flex; flex-direction: column; gap: 7px; }
.plan-features li { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 8px; font-weight: 500; }
.plan-features li::before { content: '✓'; color: var(--green); font-weight: 800; font-size: 14px; flex-shrink: 0; }
.plan-actions { display: flex; gap: 8px; }
.plan-users-count { font-size: 12px; color: var(--text-2); margin-bottom: 12px; font-weight: 500; }

/* ── DAYS SELECTOR ───────────────────────────── */
.days-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.day-btn { padding: 6px 11px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 700; color: var(--text-2); background: var(--surface); transition: all .15s; user-select: none; }
.day-btn.on { background: var(--green-light); color: #15803D; border-color: #86EFAC; }

/* ── UTILITIES ───────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.flex-end { display: flex; justify-content: flex-end; gap: 8px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-sm { font-size: 12px; color: var(--text-2); font-weight: 500; }
.text-center { text-align: center; }
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty-state .empty-icon { font-size: 52px; margin-bottom: 14px; }
.empty-state p { font-size: 14px; font-weight: 500; line-height: 1.6; }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-top-color: white; border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
.admin-only { display: none; }
body.is-admin .admin-only { display: flex; }
body.is-admin nav .admin-only { display: block; }

@keyframes fadeIn { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }
.card, .stat, .conn-card, .plan-card { animation: fadeIn .3s ease; }

/* Login/App visibility control */
#app { display: none; }
.login-page { display: flex; }
.login-page[style*="display: none"] { visibility: hidden !important; position: fixed !important; z-index: -999 !important; pointer-events: none !important; }
