:root {
    --wa-green: #25D366;
    --wa-dark-green: #075E54;
    --bg-dark: #111b21;
    --bg-card: #202c33;
    --bg-input: #2a3942;
    --border-color: #2a3942;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --success: #00a884;
    --error: #ea4335;
    --blue: #53bdeb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--wa-green);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--bg-input);
    border-radius: 20px;
    font-size: 13px;
}

.license-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    background: var(--wa-green);
}

.admin-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 18px;
}

.admin-btn:hover {
    background: #ff9500;
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-input);
    border-radius: 20px;
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--error);
    animation: pulse 2s infinite;
}

.status-pill.connected .status-dot {
    background: var(--success);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.logout-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-input);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logout-btn svg {
    width: 20px;
    height: 20px;
}

.logout-btn:hover {
    background: var(--error);
    color: white;
}

/* Main */
.main {
    flex: 1;
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

/* QR Section */
.qr-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 500px;
}

.qr-card {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 40px;
    background: var(--bg-card);
    padding: 40px;
    border-radius: 16px;
}

.qr-box {
    width: 240px;
    height: 240px;
    background: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qrCode {
    max-width: 220px;
    border-radius: 8px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #eee;
    border-top-color: var(--wa-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.qr-info h2 {
    color: var(--wa-green);
    margin-bottom: 20px;
}

.qr-info ol {
    list-style: none;
    counter-reset: steps;
}

.qr-info li {
    counter-increment: steps;
    padding: 12px 0 12px 48px;
    position: relative;
    color: var(--text-secondary);
}

.qr-info li::before {
    content: counter(steps);
    position: absolute;
    left: 0;
    width: 32px;
    height: 32px;
    background: var(--wa-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
}

/* Stats */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 32px;
    font-weight: 700;
    color: var(--wa-green);
}

.stat-card.success .stat-num {
    color: var(--success);
}

.stat-card.error .stat-num {
    color: var(--error);
}

.stat-lbl {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab {
    flex: 1;
    padding: 14px;
    background: var(--bg-card);
    border: none;
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
}

.tab:hover {
    background: var(--bg-input);
}

.tab.active {
    background: var(--wa-green);
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form */
.form-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-weight: 500;
}

select,
textarea,
input[type="text"] {
    width: 100%;
    padding: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    margin-bottom: 10px;
}

select:focus,
textarea:focus,
input:focus {
    outline: none;
    border-color: var(--wa-green);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.tip {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 10px 14px;
    background: rgba(37, 211, 102, 0.1);
    border-radius: 8px;
    border-left: 3px solid var(--wa-green);
}

.tip code {
    color: var(--wa-green);
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
}

.upload-box {
    padding: 20px;
    border: 2px dashed var(--border-color);
    border-radius: 10px;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
}

.upload-box:hover {
    border-color: var(--wa-green);
    background: rgba(37, 211, 102, 0.05);
}

.file-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-input);
    border-radius: 8px;
    margin-top: 10px;
}

.file-preview button {
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 16px;
}

.info-box {
    padding: 14px;
    background: rgba(83, 189, 235, 0.1);
    border-left: 3px solid var(--blue);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.send-btn {
    width: 100%;
    padding: 16px;
    background: var(--wa-green);
    border: none;
    border-radius: 10px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.send-btn:hover:not(:disabled) {
    background: var(--wa-dark-green);
    transform: translateY(-2px);
}

.send-btn:disabled {
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.progress-box {
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: 10px;
}

.progress-bar {
    height: 10px;
    background: var(--bg-dark);
    border-radius: 5px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: var(--wa-green);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.live-log {
    max-height: 150px;
    overflow-y: auto;
    font-size: 12px;
    font-family: monospace;
}

.log-entry {
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color);
}

.log-entry.sent {
    color: var(--success);
}

.log-entry.failed {
    color: var(--error);
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 16px;
}

.add-btn {
    padding: 8px 16px;
    background: var(--wa-green);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
}

/* Template/Log Items */
.item-card {
    background: var(--bg-input);
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.item-card h4 {
    color: var(--wa-green);
    font-size: 14px;
    margin-bottom: 4px;
}

.item-card p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.item-card button {
    padding: 5px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-right: 6px;
}

.edit-btn {
    background: var(--blue);
    color: white;
}

.delete-btn {
    background: var(--error);
    color: white;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
}

.status-badge.sent {
    background: rgba(0, 168, 132, 0.2);
    color: var(--success);
}

.status-badge.failed {
    background: rgba(234, 67, 53, 0.2);
    color: var(--error);
}

.empty-msg {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
}

.modal-box {
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 420px;
}

.modal-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.modal-head button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 16px;
}

.modal-body input,
.modal-body textarea {
    margin-bottom: 12px;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    padding: 10px 20px;
    background: var(--bg-input);
    border: none;
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
}

.btn-save {
    padding: 10px 20px;
    background: var(--wa-green);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1001;
}

.toast {
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: 8px;
    margin-top: 8px;
    font-size: 14px;
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left-color: var(--error);
}

@media (max-width: 700px) {
    .qr-card {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .qr-info ol {
        text-align: left;
    }

    .stats-row {
        grid-template-columns: 1fr;
    }
}