/* ===== Variables ===== */
:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --bg-dark: #0f0f23;
    --bg-card: #1a1a2e;
    --bg-card-hover: #252542;
    --bg-input: #16213e;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b7280;
    
    --border: #2d2d44;
    --border-light: #3d3d5c;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

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

/* ===== App Layout ===== */
.app {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    font-size: 28px;
}

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

.nav {
    flex: 1;
    padding: 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    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.online {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    margin-left: 260px;
    padding: 24px;
    background: var(--bg-dark);
}

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

.page-title {
    font-size: 28px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 12px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 15px;
}

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

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

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

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-success {
    background: linear-gradient(135deg, #059669, var(--success));
    color: white;
}

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

.btn-warning {
    background: linear-gradient(135deg, #d97706, var(--warning));
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, var(--danger));
    color: white;
}

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

.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--primary-light));
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-icon.success::before { content: ''; }
.stat-icon.error::before { content: ''; }

.stat-content {
    margin-bottom: 8px;
}

.stat-value {
    display: block;
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-progress {
    height: 4px;
    background: var(--bg-input);
    border-radius: 2px;
    margin: 12px 0 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 2px;
    transition: width 0.3s;
}

.stat-limit {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Upload Section ===== */
.upload-section {
    margin-bottom: 32px;
}

.upload-area {
    background: var(--bg-card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--bg-card-hover);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.upload-area h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-info {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--border);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.file-icon {
    font-size: 24px;
}

.file-name {
    display: block;
    font-weight: 500;
}

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

/* ===== Campaign Control ===== */
.campaign-control {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
}

.campaign-control h2 {
    margin-bottom: 20px;
}

.control-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.control-item label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.control-item input,
.control-item select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.control-item input:focus,
.control-item select:focus {
    outline: none;
    border-color: var(--primary);
}

.control-actions {
    display: flex;
    gap: 12px;
}

/* ===== Progress Section ===== */
.progress-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
}

.progress-section h2 {
    margin-bottom: 20px;
}

.progress-container {
    margin-bottom: 20px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-bar-lg {
    height: 12px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    border-radius: 6px;
    transition: width 0.3s;
}

.current-lead {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-input);
    border-radius: var(--radius);
}

.lead-name {
    font-weight: 600;
}

.lead-phone {
    color: var(--text-secondary);
}

.lead-status {
    margin-left: auto;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.lead-status.sending {
    background: rgba(59, 130, 246, 0.2);
    color: var(--info);
}

.lead-status.success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.lead-status.error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* ===== Table ===== */
.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-actions {
    display: flex;
    gap: 12px;
}

.search-input {
    padding: 10px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    width: 250px;
}

.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-input);
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.data-table tr:hover td {
    background: var(--bg-card-hover);
}

.empty-state {
    text-align: center;
    padding: 48px !important;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.empty-hint {
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== Messages Tab ===== */
.messages-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.message-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
}

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

.message-variation {
    font-weight: 600;
}

.message-badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.message-badge.formal {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.message-badge.casual {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.message-badge.direct {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.message-preview {
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.6;
    min-height: 150px;
}

/* ===== Logs Tab ===== */
.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.logs-filters {
    display: flex;
    gap: 12px;
}

.logs-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.log-item {
    display: grid;
    grid-template-columns: 100px 40px 1fr 150px 1fr;
    gap: 16px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    align-items: center;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item.success {
    border-left: 3px solid var(--success);
}

.log-item.error {
    border-left: 3px solid var(--danger);
}

.log-time {
    color: var(--text-secondary);
    font-size: 13px;
}

.log-status {
    font-size: 16px;
}

.log-lead {
    font-weight: 500;
}

.log-phone {
    color: var(--text-secondary);
    font-size: 13px;
}

.log-message {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== Settings Tab ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.settings-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.settings-card h3 {
    margin-bottom: 20px;
}

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

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

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px;
    background: rgba(16, 185, 129, 0.1);
    border-radius: var(--radius-sm);
    color: var(--success);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
}

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

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

.modal-body {
    padding: 24px;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1001;
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 3px solid var(--success);
}

.toast.error {
    border-left: 3px solid var(--danger);
}

.toast.info {
    border-left: 3px solid var(--info);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Tabs ===== */
.tab-content {
    display: none;
}

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

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .control-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .messages-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .settings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .main {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .control-grid {
        grid-template-columns: 1fr;
    }
    
    .messages-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== Light Theme ===== */
:root[data-theme="light"] {
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f8f8f8;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #6b7280;
    --border: #e0e0e0;
    --border-light: #d0d0d0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}


:root[data-theme="light"], body[data-theme="light"] {
    --bg-dark: #f5f5f5;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f0f0;
    --bg-input: #f8f8f8;
    
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #6b7280;
    
    --border: #e0e0e0;
    --border-light: #d0d0d0;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Sidebar */
:root[data-theme="light"], body[data-theme="light"] .sidebar {
    background: var(--bg-card);
    border-right-color: var(--border);
}

:root[data-theme="light"], body[data-theme="light"] .nav-item:hover {
    background: var(--bg-card-hover);
}

/* Cards */
:root[data-theme="light"], body[data-theme="light"] .stat-card {
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

:root[data-theme="light"], body[data-theme="light"] .stat-card::before {
    opacity: 0.3;
}

:root[data-theme="light"], body[data-theme="light"] .campaign-control,
:root[data-theme="light"], body[data-theme="light"] .progress-section,
:root[data-theme="light"], body[data-theme="light"] .table-container,
:root[data-theme="light"], body[data-theme="light"] .logs-container,
:root[data-theme="light"], body[data-theme="light"] .settings-card,
:root[data-theme="light"], body[data-theme="light"] .message-card {
    background: var(--bg-card);
    box-shadow: var(--shadow);
}

/* Upload */
:root[data-theme="light"], body[data-theme="light"] .upload-area {
    background: var(--bg-card);
    border-color: var(--border);
}

:root[data-theme="light"], body[data-theme="light"] .upload-info {
    background: var(--bg-card);
    border-color: var(--border);
}

/* Inputs */
:root[data-theme="light"], body[data-theme="light"] input,
:root[data-theme="light"], body[data-theme="light"] select,
:root[data-theme="light"], body[data-theme="light"] textarea {
    background: var(--bg-input);
    border-color: var(--border);
    color: var(--text-primary);
}

:root[data-theme="light"], body[data-theme="light"] input:focus,
:root[data-theme="light"], body[data-theme="light"] select:focus,
:root[data-theme="light"], body[data-theme="light"] textarea:focus {
    border-color: var(--primary);
}

/* Buttons */
:root[data-theme="light"], body[data-theme="light"] .btn-secondary {
    background: var(--bg-card);
    border-color: var(--border);
}

:root[data-theme="light"], body[data-theme="light"] .btn-secondary:hover {
    background: var(--bg-card-hover);
}

/* Table */
:root[data-theme="light"], body[data-theme="light"] .data-table th {
    background: var(--bg-input);
}

:root[data-theme="light"], body[data-theme="light"] .data-table tr:hover td {
    background: var(--bg-card-hover);
}

/* Messages */
:root[data-theme="light"], body[data-theme="light"] .message-preview {
    background: var(--bg-input);
}

/* Logs */
:root[data-theme="light"], body[data-theme="light"] .log-item {
    border-bottom-color: var(--border);
}

/* Modal */
:root[data-theme="light"], body[data-theme="light"] .modal-content {
    background: var(--bg-card);
}

:root[data-theme="light"], body[data-theme="light"] .modal-header {
    border-bottom-color: var(--border);
}

/* Toast */
:root[data-theme="light"], body[data-theme="light"] .toast {
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
}

/* Progress */
:root[data-theme="light"], body[data-theme="light"] .progress-bar-lg,
:root[data-theme="light"], body[data-theme="light"] .stat-progress {
    background: var(--bg-input);
}

/* Status dots */
:root[data-theme="light"], body[data-theme="light"] .connection-status {
    background: rgba(16, 185, 129, 0.1);
}

/* Download Template */
.download-template {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.download-template .btn {
    text-decoration: none;
}

.download-template .btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* Light theme for download template */
body[data-theme="light"] .download-template {
    background: var(--bg-card);
    border-color: var(--border);
}
