/* CSS Variables */
:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-card: #1a2332;
    --bg-card-hover: #1f2937;
    --accent-primary: #25d366;
    --accent-secondary: #128c7e;
    --accent-glow: rgba(37, 211, 102, 0.3);
    --text-primary: #f0f4f8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border-color: #2d3a4f;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px var(--accent-glow);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Background Pattern */
.background-pattern {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(37, 211, 102, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(18, 140, 126, 0.08) 0%, transparent 50%),
        linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.background-pattern::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 50px,
            rgba(37, 211, 102, 0.02) 50px,
            rgba(37, 211, 102, 0.02) 51px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 50px,
            rgba(37, 211, 102, 0.02) 50px,
            rgba(37, 211, 102, 0.02) 51px
        );
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.whatsapp-icon {
    width: 48px;
    height: 48px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.navbar-brand h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
    font-weight: 500;
}

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

.status-badge.not_running .status-dot { background: var(--text-muted); }
.status-badge.waiting_qr .status-dot { background: var(--warning); }
.status-badge.ready .status-dot { background: var(--success); }
.status-badge.error .status-dot { background: var(--danger); }

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

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(37, 211, 102, 0.3);
    box-shadow: var(--shadow-sm);
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h2::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 2px;
}

/* Connection Section */
.connection-section {
    grid-column: 1 / -1;
}

.button-group {
    display: flex;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-primary:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

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

.btn-danger:hover:not(:disabled) {
    background: var(--danger-hover);
    transform: translateY(-2px);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.btn-success:hover:not(:disabled) {
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

.btn-full {
    width: 100%;
}

/* QR Section */
.qr-section {
    display: flex;
    flex-direction: column;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.qr-placeholder {
    width: 200px;
    height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}

.qr-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.qr-placeholder p {
    font-size: 0.875rem;
    text-align: center;
    padding: 0 1rem;
}

.qr-image {
    width: 200px;
    height: 200px;
    border-radius: var(--radius-md);
    border: 3px solid var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.qr-instructions {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Message Section */
.message-section {
    display: flex;
    flex-direction: column;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.input-with-icon {
    position: relative;
}

.input-with-icon svg {
    position: absolute;
    left: 12px;
    top: 12px;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-with-icon input,
.input-with-icon textarea {
    padding-left: 44px;
}

input, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}

input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

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

.form-select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.9375rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.file-upload-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.file-input-hidden {
    display: none !important;
}

.file-name {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-style: italic;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Progress Section */
.progress-section {
    grid-column: 1 / -1;
}

.progress-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.progress-bar {
    flex: 1;
    height: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-lg);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-glow);
    min-width: 2%;
}

.progress-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 80px;
    text-align: right;
}

.progress-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-status {
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.progress-last {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--accent-primary);
}

.checkbox-label:hover {
    color: var(--text-primary);
}

/* Log Section */
.log-section {
    grid-column: 1 / -1;
}

.log-container {
    max-height: 200px;
    overflow-y: auto;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
}

.log-entry {
    display: flex;
    gap: 0.75rem;
    padding: 0.5rem;
    font-size: 0.8125rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.log-entry:last-child {
    margin-bottom: 0;
}

.log-time {
    color: var(--text-muted);
    font-family: 'Courier New', monospace;
    min-width: 70px;
}

.log-message {
    flex: 1;
}

.log-entry.info { border-left: 3px solid var(--info); }
.log-entry.success { border-left: 3px solid var(--success); }
.log-entry.error { border-left: 3px solid var(--danger); }
.log-entry.warning { border-left: 3px solid var(--warning); }

/* Footer */
.footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    .navbar {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

/* Loading Animation */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Screenshot Styles */
.screenshot-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1.5rem;
    color: var(--text-secondary);
}

.screenshot-loading .loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.screenshot-loading .timer-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem 0;
}

.screenshot-loading .timer-circle {
    position: relative;
    width: 140px;
    height: 140px;
}

.screenshot-loading .timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.screenshot-loading .timer-bg {
    fill: none;
    stroke: var(--border-color);
    stroke-width: 8;
}

.screenshot-loading .timer-progress {
    fill: none;
    stroke: var(--accent-primary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 339.292;
    stroke-dashoffset: 339.292;
    transition: stroke-dashoffset 0.5s ease;
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.screenshot-loading .timer-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.screenshot-loading .timer-seconds {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1;
    text-shadow: 0 0 10px var(--accent-glow);
}

.screenshot-loading .timer-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.screenshot-loading p {
    font-size: 1rem;
    margin: 0;
    font-weight: 500;
}

.screenshot-loading .loading-note {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.screenshot-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    height: 100%;
}

.screenshot-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.screenshot-download {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.screenshot-download:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.chat-screenshot {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.screenshot-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 0.5rem;
    color: var(--danger);
}

.screenshot-error p {
    margin: 0;
}

.screenshot-error .error-message {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.modal-content h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.modal-content p {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

/* Account Info Styles */
.account-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.account-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.account-code-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.account-code-container label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.account-code-display {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-secondary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.account-code-display code {
    font-family: 'Courier New', monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-primary);
    letter-spacing: 0.1em;
    flex: 1;
}

.btn-copy {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-copy:hover {
    background: var(--bg-card-hover);
    color: var(--accent-primary);
}

.btn-copy svg {
    width: 18px;
    height: 18px;
}

/* Leads Table Styles */
.leads-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.leads-table-container {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.leads-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
}

.leads-table thead {
    background: var(--bg-card);
}

.leads-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
}

.leads-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.leads-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.leads-table tbody tr:last-child td {
    border-bottom: none;
}

.leads-table .loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.leads-table .status-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.leads-table .status-badge.fetched {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.leads-table .status-badge.not-fetched {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

