/* ==========================================================================
   Disparador WhatsApp — Premium Dark Theme
   ========================================================================== */

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

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #06060b;
    --bg-secondary: #0d0d15;
    --bg-card: rgba(15, 15, 25, 0.7);
    --bg-card-hover: rgba(20, 20, 35, 0.85);
    --bg-input: rgba(15, 15, 25, 0.6);
    --border-color: rgba(124, 58, 237, 0.15);
    --border-hover: rgba(124, 58, 237, 0.35);
    --border-focus: rgba(124, 58, 237, 0.6);

    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-dark: #5b21b6;
    --accent-glow: rgba(124, 58, 237, 0.25);

    --green: #10b981;
    --green-light: #34d399;
    --green-glow: rgba(16, 185, 129, 0.2);

    --red: #ef4444;
    --red-light: #f87171;
    --red-glow: rgba(239, 68, 68, 0.2);

    --yellow: #f59e0b;
    --yellow-glow: rgba(245, 158, 11, 0.2);

    --blue: #3b82f6;

    --text-primary: #f1f1f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --glass-bg: rgba(15, 15, 30, 0.6);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-blur: 20px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 30px var(--accent-glow);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* Background gradient */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(124, 58, 237, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(16, 185, 129, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.5); }

/* ---------- Layout ---------- */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- Header ---------- */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 0;
    border-bottom: 1px solid var(--glass-border);
    margin-bottom: 24px;
}

.app-header .logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.app-header .logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    box-shadow: var(--shadow-glow);
}

.app-header h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-header .subtitle {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 2px;
}

.header-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

.status-dot.connected {
    background: var(--green);
    box-shadow: 0 0 8px var(--green-glow);
    animation: pulse-dot 2s infinite;
}

.status-dot.disconnected {
    background: var(--red);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

/* ---------- Tabs ---------- */
.tabs-nav {
    display: flex;
    gap: 4px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 5px;
    margin-bottom: 24px;
}

.tab-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    position: relative;
    min-width: 0;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(124, 58, 237, 0.08);
}

.tab-btn.active {
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.2), rgba(167, 139, 250, 0.1));
    color: var(--accent-light);
    box-shadow: 0 2px 12px rgba(124, 58, 237, 0.15);
}

.tab-btn .tab-icon {
    font-size: 16px;
}

.tab-btn .badge {
    background: var(--accent);
    color: white;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 600;
}

/* ---------- Tab Content ---------- */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- Glass Card ---------- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    transition: all var(--transition-normal);
}

.card:hover {
    border-color: var(--border-color);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.card-title .icon {
    font-size: 20px;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

/* ---------- Form Elements ---------- */
.form-group {
    margin-bottom: 18px;
}

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

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: all var(--transition-fast);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
    box-shadow: 0 4px 14px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-success {
    background: linear-gradient(135deg, var(--green), #059669);
    color: white;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--red), #dc2626);
    color: white;
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-light);
    background: rgba(124, 58, 237, 0.06);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 12px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* ---------- Instance Grid ---------- */
.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.instance-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.instance-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--text-muted);
    transition: background var(--transition-normal);
}

.instance-card.connected::before { background: var(--green); }
.instance-card.close::before { background: var(--red); }
.instance-card.connecting::before { background: var(--yellow); }

.instance-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.instance-card.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), var(--shadow-glow);
}

.instance-card .instance-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.instance-card .instance-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.instance-card .instance-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.instance-card .instance-info h3 {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.instance-card .instance-info .instance-name-sub {
    font-size: 12px;
    color: var(--text-muted);
}

.instance-card .instance-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 4px;
}

.instance-card .instance-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.instance-card.connected .instance-status .dot { background: var(--green); box-shadow: 0 0 6px var(--green-glow); animation: pulse-dot 2s infinite; }
.instance-card.connected .instance-status { color: var(--green-light); }
.instance-card.close .instance-status .dot { background: var(--red); }
.instance-card.close .instance-status { color: var(--red-light); }
.instance-card.connecting .instance-status .dot { background: var(--yellow); animation: pulse-dot 1s infinite; }
.instance-card.connecting .instance-status { color: var(--yellow); }

.instance-card .check-icon {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 22px;
    height: 22px;
    border: 2px solid var(--glass-border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    font-size: 13px;
}

.instance-card.selected .check-icon {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Instance card action buttons */
.instance-card .instance-actions {
    display: flex;
    gap: 6px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--glass-border);
}

.instance-card .inst-btn {
    flex: 1;
    padding: 6px 8px;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    white-space: nowrap;
}

.instance-card .inst-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.instance-card .inst-btn.connect {
    color: var(--green-light);
    border-color: rgba(16, 185, 129, 0.2);
}
.instance-card .inst-btn.connect:hover {
    background: var(--green-glow);
    border-color: var(--green);
}

.instance-card .inst-btn.disconnect {
    color: var(--yellow);
    border-color: rgba(245, 158, 11, 0.2);
}
.instance-card .inst-btn.disconnect:hover {
    background: var(--yellow-glow);
    border-color: var(--yellow);
}

.instance-card .inst-btn.delete {
    color: var(--red-light);
    border-color: rgba(239, 68, 68, 0.2);
}
.instance-card .inst-btn.delete:hover {
    background: var(--red-glow);
    border-color: var(--red);
}

/* QR Code image */
#qrContainer img {
    width: 240px;
    height: 240px;
    border-radius: var(--radius-md);
    border: 3px solid var(--accent);
    box-shadow: var(--shadow-glow);
    image-rendering: pixelated;
}

.qr-connected-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.qr-connected-badge .check-big {
    width: 80px;
    height: 80px;
    background: var(--green-glow);
    border: 2px solid var(--green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    animation: fadeIn 0.4s ease;
}


/* ---------- Upload Zone ---------- */
.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: rgba(124, 58, 237, 0.02);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(124, 58, 237, 0.06);
}

.upload-zone .upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.upload-zone .upload-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.upload-zone .upload-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.upload-zone.has-file {
    border-style: solid;
    border-color: var(--green);
    background: rgba(16, 185, 129, 0.04);
}

.upload-zone.has-file .upload-icon { color: var(--green); opacity: 1; }

/* ---------- Data Preview Table ---------- */
.data-preview {
    overflow-x: auto;
    margin-top: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.data-preview table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-preview th {
    background: rgba(124, 58, 237, 0.1);
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--accent-light);
    white-space: nowrap;
    border-bottom: 1px solid var(--glass-border);
}

.data-preview td {
    padding: 8px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-preview tr:hover td {
    background: rgba(124, 58, 237, 0.04);
}

/* ---------- Message Editor ---------- */
.message-editor {
    margin-bottom: 16px;
}

.message-block {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: all var(--transition-normal);
}

.message-block:hover {
    border-color: var(--border-color);
}

.message-block .msg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.message-block .msg-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
}

.message-block .msg-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all var(--transition-fast);
}

.message-block .msg-remove:hover {
    color: var(--red);
    background: var(--red-glow);
}

.message-block textarea {
    width: 100%;
    min-height: 90px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    padding: 12px;
    resize: vertical;
    outline: none;
    transition: all var(--transition-fast);
}

.message-block textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Variable tags */
.var-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.var-tag {
    padding: 4px 12px;
    background: rgba(124, 58, 237, 0.12);
    border: 1px solid rgba(124, 58, 237, 0.25);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--accent-light);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
}

.var-tag:hover {
    background: rgba(124, 58, 237, 0.25);
    border-color: var(--accent);
    transform: translateY(-1px);
}

/* ---------- Delay Config ---------- */
.delay-config {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.delay-config .delay-input {
    display: flex;
    align-items: center;
    gap: 8px;
}

.delay-config input[type="number"] {
    width: 80px;
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    text-align: center;
    outline: none;
    transition: all var(--transition-fast);
}

.delay-config input[type="number"]:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.delay-config .delay-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.delay-config .delay-separator {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ---------- Phone Column Selector ---------- */
.phone-selector {
    margin: 16px 0;
}

/* ---------- Selected Summary ---------- */
.selected-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.selected-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 20px;
    font-size: 12px;
    color: var(--green-light);
    font-weight: 500;
}

.selected-chip .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
}

/* ---------- Preview Modal ---------- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    max-width: 700px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: var(--shadow-lg);
    animation: modalSlide 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes modalSlide {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal .preview-section {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.modal .preview-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.modal .preview-section p,
.modal .preview-section .preview-value {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal .preview-message {
    background: rgba(16, 185, 129, 0.06);
    border-left: 3px solid var(--green);
    padding: 12px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.modal .preview-message .var-highlight {
    color: var(--accent-light);
    font-weight: 600;
    background: rgba(124, 58, 237, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--glass-border);
}

/* ---------- Progress Panel ---------- */
.progress-panel {
    display: none;
}

.progress-panel.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.progress-bar-container {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    height: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    position: relative;
}

.progress-bar {
    height: 100%;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--accent), var(--green));
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-card.sent .stat-value { color: var(--green-light); }
.stat-card.failed .stat-value { color: var(--red-light); }
.stat-card.total .stat-value { color: var(--accent-light); }
.stat-card.remaining .stat-value { color: var(--yellow); }

/* Instance progress */
.instance-progress-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.instance-progress-item {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px;
}

.instance-progress-item .ip-name {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.instance-progress-item .ip-bar {
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.instance-progress-item .ip-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--green));
    border-radius: 3px;
    transition: width 0.5s ease;
}

.instance-progress-item .ip-stats {
    font-size: 11px;
    color: var(--text-muted);
}

/* Log feed */
.log-feed {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}

.log-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    font-size: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.02);
    transition: background var(--transition-fast);
    animation: logSlide 0.2s ease;
}

@keyframes logSlide {
    from { opacity: 0; transform: translateX(-10px); }
    to { opacity: 1; transform: translateX(0); }
}

.log-entry:hover {
    background: rgba(124, 58, 237, 0.04);
}

.log-entry .log-time {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    font-size: 11px;
    white-space: nowrap;
}

.log-entry .log-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.log-entry .log-status.sent { background: var(--green); }
.log-entry .log-status.failed { background: var(--red); }

.log-entry .log-phone {
    color: var(--text-primary);
    font-weight: 500;
    min-width: 120px;
}

.log-entry .log-instance {
    color: var(--accent-light);
    font-size: 11px;
}

.log-entry .log-msg {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

/* ---------- History ---------- */
.campaign-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.history-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    transform: translateX(4px);
}

.history-item .hi-status-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.history-item .hi-status-icon.finished {
    background: var(--green-glow);
    color: var(--green);
}

.history-item .hi-status-icon.stopped {
    background: var(--yellow-glow);
    color: var(--yellow);
}

.history-item .hi-status-icon.running {
    background: var(--accent-glow);
    color: var(--accent-light);
}

.history-item .hi-status-icon.failed {
    background: var(--red-glow);
    color: var(--red);
}

.history-item .hi-info {
    flex: 1;
}

.history-item .hi-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 2px;
}

.history-item .hi-date {
    font-size: 12px;
    color: var(--text-muted);
}

.history-item .hi-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
}

.history-item .hi-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.history-item .hi-stat.sent { color: var(--green-light); }
.history-item .hi-stat.failed { color: var(--red-light); }
.history-item .hi-stat.total { color: var(--text-secondary); }

.history-item .hi-actions {
    display: flex;
    gap: 8px;
}

/* ---------- Toast ---------- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 400px;
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
}

.toast.success {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.3);
    color: var(--green-light);
}

.toast.error {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--red-light);
}

.toast.info {
    background: rgba(124, 58, 237, 0.15);
    border-color: rgba(124, 58, 237, 0.3);
    color: var(--accent-light);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: toastOut 0.3s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(40px); }
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

.empty-state p {
    font-size: 14px;
}

/* ---------- Loading Spinner ---------- */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-light);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .app-container {
        padding: 0 12px;
    }

    .app-header {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }

    .tabs-nav {
        overflow-x: auto;
    }

    .tab-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

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

    .instances-grid {
        grid-template-columns: 1fr;
    }

    .progress-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .modal {
        padding: 20px;
        max-height: 90vh;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .history-item .hi-stats {
        width: 100%;
    }
}

/* ---------- Section Divider ---------- */
.section-divider {
    height: 1px;
    background: var(--glass-border);
    margin: 24px 0;
}

/* ---------- Campaign Name Input ---------- */
.campaign-name-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.campaign-name-inline input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.campaign-name-inline input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* ---------- Info Banner ---------- */
.info-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: var(--radius-md);
    color: var(--blue);
    font-size: 13px;
    margin-bottom: 16px;
}

.info-banner .info-icon {
    font-size: 18px;
    flex-shrink: 0;
}

/* ---------- Message Templates ---------- */
.templates-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.template-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
}

.template-item .tmpl-info {
    flex: 1;
    min-width: 0;
}

.template-item .tmpl-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-item .tmpl-preview {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-item .tmpl-msgs-count {
    font-size: 11px;
    color: var(--accent-light);
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid rgba(124, 58, 237, 0.2);
    border-radius: 20px;
    padding: 2px 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.template-item .tmpl-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.template-item .tmpl-btn {
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--glass-border);
    background: transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    color: var(--text-secondary);
}

.template-item .tmpl-btn.load {
    color: var(--accent-light);
    border-color: rgba(124, 58, 237, 0.25);
}
.template-item .tmpl-btn.load:hover {
    background: rgba(124, 58, 237, 0.12);
    border-color: var(--accent);
}

.template-item .tmpl-btn.del {
    color: var(--red-light);
    border-color: rgba(239, 68, 68, 0.2);
}
.template-item .tmpl-btn.del:hover {
    background: var(--red-glow);
    border-color: var(--red);
}

/* Messages bar above editor */
.messages-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

/* History download button */
.hi-download-btn {
    padding: 5px 12px;
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--green-light);
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hi-download-btn:hover {
    background: var(--green-glow);
    border-color: var(--green);
}

/* Save template input inline */
.save-template-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--glass-border);
}

.save-template-row input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg-input);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    outline: none;
    transition: all var(--transition-fast);
}

.save-template-row input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
