:root {
    --sidebar-width: 220px;
    --green: #25D366;
    --green-dark: #128C7E;
}

/* ── PWA Install Banner ── */
#pwa-install-banner {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 900;
    max-width: 480px;
    width: calc(100% - 32px);
    animation: slideUp 0.3s ease;
}
#pwa-install-banner img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    flex-shrink: 0;
}
#pwa-install-banner .pwa-text { flex: 1; }
#pwa-install-banner .pwa-text strong { display: block; font-size: 0.9rem; margin-bottom: 2px; }
#pwa-install-banner .pwa-text span { font-size: 0.78rem; color: #666; }
#pwa-install-banner .pwa-actions { display: flex; gap: 8px; flex-shrink: 0; }
#pwa-install-banner .pwa-ios-steps {
    font-size: 0.78rem;
    color: #555;
    margin-top: 6px;
    line-height: 1.6;
}
@keyframes slideUp {
    from { transform: translateX(-50%) translateY(80px); opacity: 0; }
    to   { transform: translateX(-50%) translateY(0);   opacity: 1; }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #f0f2f5;
    color: #111;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Header ── */
header {
    background: var(--green-dark);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    flex-shrink: 0;
    z-index: 10;
}
header h1 { font-size: 1.1rem; font-weight: 600; margin: 0; }
#wa-badge {
    font-size: 0.8rem;
    background: rgba(255,255,255,0.15);
    border-radius: 20px;
    padding: 4px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}
#wa-badge .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #ccc;
}
#wa-badge .dot.green { background: #4fffb0; }
#wa-badge .dot.yellow { background: #ffe066; }
#wa-badge .dot.red { background: #ff6b6b; }

/* ── Layout ── */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ── */
nav {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    padding: 12px 0;
    flex-shrink: 0;
}
nav button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px 20px;
    text-align: left;
    font-size: 0.9rem;
    color: #444;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 0;
    transition: background 0.15s;
}
nav button:hover { background: #f5f5f5; }
nav button.active {
    background: #e8f5e9;
    color: var(--green-dark);
    font-weight: 600;
    border-right: 3px solid var(--green-dark);
}
nav button .icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* ── Main content ── */
main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.view { display: none; }
.view.active { display: block; }

/* ── Cards ── */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 16px 0;
    color: #222;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: opacity 0.15s, transform 0.1s;
}
.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-green { background: var(--green); color: #fff; }
.btn-red { background: #e53935; color: #fff; }
.btn-gray { background: #e0e0e0; color: #333; }
.btn-outline { background: transparent; border: 1.5px solid var(--green-dark); color: var(--green-dark); }
.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── WhatsApp View ── */
#qr-container {
    text-align: center;
    padding: 20px 0;
}
#qr-image {
    width: 256px;
    height: 256px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}
.wa-status-msg {
    font-size: 1rem;
    color: #555;
    margin: 12px 0;
}
.loading-bar-wrap {
    background: #e0e0e0;
    border-radius: 8px;
    height: 8px;
    width: 100%;
    margin: 12px 0;
    overflow: hidden;
}
.loading-bar-fill {
    height: 100%;
    background: var(--green);
    transition: width 0.3s;
    border-radius: 8px;
}

/* ── Wizard ── */
.wizard-steps {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
}
.wizard-step {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 0.8rem;
    color: #999;
    border-bottom: 3px solid #e0e0e0;
    position: relative;
}
.wizard-step.active {
    color: var(--green-dark);
    border-bottom-color: var(--green-dark);
    font-weight: 600;
}
.wizard-step.done {
    color: var(--green);
    border-bottom-color: var(--green);
}

/* ── Drop zone ── */
.drop-zone {
    border: 2px dashed #ccc;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    color: #777;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--green);
    background: #f0fff4;
}
.drop-zone input[type=file] { display: none; }
.drop-zone .drop-icon { font-size: 2.5rem; margin-bottom: 8px; }

/* ── Contact preview ── */
.contact-table-wrap {
    overflow-x: auto;
    margin-top: 16px;
    max-height: 260px;
    overflow-y: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { background: #f5f5f5; position: sticky; top: 0; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid #eee; }
tr:last-child td { border-bottom: none; }

/* ── Message type selector ── */
.msg-type-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.msg-type-btn {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 14px 8px;
    text-align: center;
    cursor: pointer;
    font-size: 0.8rem;
    color: #555;
    transition: all 0.15s;
    background: #fff;
}
.msg-type-btn:hover { border-color: var(--green); color: var(--green-dark); }
.msg-type-btn.selected {
    border-color: var(--green-dark);
    background: #e8f5e9;
    color: var(--green-dark);
    font-weight: 600;
}
.msg-type-btn .type-icon { font-size: 1.6rem; display: block; margin-bottom: 4px; }

/* ── Form fields ── */
.field { margin-bottom: 16px; }
.field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #555;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.field input, .field textarea, .field select {
    width: 100%;
    padding: 10px 12px;
    border: 1.5px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}
.field input:focus, .field textarea:focus { border-color: var(--green-dark); }
.field textarea { resize: vertical; min-height: 100px; }
.hint { font-size: 0.75rem; color: #888; margin-top: 4px; }

/* ── Uploaded file display ── */
.uploaded-file {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0fff4;
    border: 1.5px solid var(--green);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #2e7d32;
}
.uploaded-file .remove-file {
    margin-left: auto;
    cursor: pointer;
    color: #e53935;
    font-weight: bold;
    font-size: 1rem;
    line-height: 1;
}

/* ── Campaign cards (history) ── */
.campaign-card {
    background: #fff;
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: pointer;
    transition: box-shadow 0.15s;
    display: flex;
    align-items: center;
    gap: 16px;
}
.campaign-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.12); }
.campaign-info { flex: 1; }
.campaign-name { font-weight: 600; font-size: 0.95rem; color: #222; margin-bottom: 4px; }
.campaign-meta { font-size: 0.8rem; color: #777; }
.campaign-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Status badges ── */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.badge-pending { background: #e3f2fd; color: #1565c0; }
.badge-running { background: #fff9c4; color: #f57f17; }
.badge-paused { background: #ede7f6; color: #4527a0; }
.badge-completed { background: #e8f5e9; color: #2e7d32; }
.badge-failed { background: #ffebee; color: #c62828; }

/* ── Progress bar ── */
.progress-wrap {
    background: #e0e0e0;
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--green);
    border-radius: 10px;
    transition: width 0.4s;
}

/* ── Stats row ── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 20px 0;
}
.stat-box {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.stat-num { font-size: 2rem; font-weight: 700; }
.stat-label { font-size: 0.75rem; color: #777; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-sent .stat-num { color: var(--green-dark); }
.stat-failed .stat-num { color: #e53935; }
.stat-pending .stat-num { color: #555; }

/* ── Activity log ── */
.activity-log {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    height: 220px;
    overflow-y: auto;
    padding: 10px;
    font-size: 0.82rem;
    font-family: 'Consolas', monospace;
}
.log-entry { padding: 4px 0; border-bottom: 1px solid #f0f0f0; }
.log-entry:last-child { border-bottom: none; }
.log-sent { color: #2e7d32; }
.log-failed { color: #c62828; }
.log-skipped { color: #f57f17; }

/* ── Toast ── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: #333;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 0.875rem;
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    animation: slideIn 0.2s ease;
}
.toast.error { background: #c62828; }
.toast.success { background: #2e7d32; }
@keyframes slideIn {
    from { transform: translateX(40px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ── Wizard nav ── */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

/* ── Empty state ── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state p { font-size: 0.9rem; }

/* ── Section title ── */
.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: #222;
    margin: 0 0 20px 0;
}

/* ── Login wall ── */
#login-wall {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── License wall ── */
#license-wall {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}
.license-wall-box {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ── License expiry warning ── */
.license-warning {
    background: #fff8e1;
    border: 1.5px solid #f9a825;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    color: #e65100;
    margin-bottom: 16px;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    nav { width: 56px; }
    nav button span:not(.icon) { display: none; }
    main { padding: 16px; }
    .msg-type-grid { grid-template-columns: repeat(2, 1fr); }
    .stats-row { grid-template-columns: repeat(3, 1fr); }
}
