/* EVADAV Panel - Complete Styles */

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f5f7fa; color: #333; line-height: 1.6; }

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

/* Sidebar */
.sidebar { 
    width: 260px; 
    background: #1a1f36; 
    color: #fff; 
    position: fixed; 
    height: 100vh; 
    overflow-y: auto;
    z-index: 1000;
}
.sidebar-header { 
    padding: 20px; 
    border-bottom: 1px solid #2d3354; 
}
.sidebar-header h1 { 
    font-size: 20px; 
    color: #00d4aa; 
    font-weight: 700;
}
.nav-group { margin: 10px 0; }
.nav-group-title { 
    padding: 10px 20px; 
    font-size: 11px; 
    text-transform: uppercase; 
    color: #8b92b4; 
    font-weight: 600; 
}
.nav-item { 
    padding: 12px 20px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 14px;
}
.nav-item:hover { background: #252b4b; }
.nav-item.active { 
    background: #252b4b; 
    border-left-color: #00d4aa; 
    color: #00d4aa; 
}
.nav-item i { width: 20px; text-align: center; }

/* Main Content */
.main { 
    flex: 1; 
    margin-left: 260px; 
    min-height: 100vh;
}

/* Header */
.header { 
    height: 60px; 
    background: #fff; 
    border-bottom: 1px solid #e1e4e8; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding: 0 30px; 
    position: sticky; 
    top: 0; 
    z-index: 100;
}
.header h2 { font-size: 20px; font-weight: 600; }
.status { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 6px 12px; 
    border-radius: 20px; 
    font-size: 13px; 
    font-weight: 500;
}
.status.connected { background: #d4edda; color: #155724; }
.status.error { background: #f8d7da; color: #721c24; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* Content */
.content { padding: 30px; }
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards */
.card { 
    background: #fff; 
    border-radius: 8px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1); 
    margin-bottom: 20px;
}
.card-header { 
    padding: 20px; 
    border-bottom: 1px solid #e1e4e8; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Stats Grid */
.stats-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 20px; 
    margin-bottom: 30px; 
}
.stat-card { 
    background: #fff; 
    padding: 20px; 
    border-radius: 8px; 
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card h4 { 
    font-size: 12px; 
    color: #666; 
    text-transform: uppercase; 
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}
.stat-value { 
    font-size: 28px; 
    font-weight: 700; 
    color: #1a1f36;
}

/* Tables */
.table-container { overflow-x: auto; }
table { 
    width: 100%; 
    border-collapse: collapse;
    font-size: 13px;
}
th, td { 
    padding: 12px; 
    text-align: left; 
    border-bottom: 1px solid #e1e4e8; 
}
th { 
    background: #f8f9fa; 
    font-weight: 600; 
    text-transform: uppercase; 
    font-size: 11px; 
    color: #666;
    letter-spacing: 0.5px;
}
tr:hover { background: #f8f9fa; }

/* Buttons */
.btn { 
    padding: 8px 16px; 
    border: none; 
    border-radius: 4px; 
    font-size: 13px; 
    cursor: pointer; 
    transition: all 0.2s;
    font-weight: 500;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn-primary { background: #00d4aa; color: #fff; }
.btn-primary:hover { background: #00b894; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-warning { background: #ffc107; color: #212529; }
.btn-warning:hover { background: #e0a800; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 15px; }
.form-group label { 
    display: block; 
    margin-bottom: 5px; 
    font-size: 13px; 
    font-weight: 500;
    color: #555;
}
.form-control { 
    width: 100%; 
    padding: 8px 12px; 
    border: 1px solid #d1d5db; 
    border-radius: 4px; 
    font-size: 13px;
    transition: border-color 0.2s;
}
.form-control:focus { 
    outline: none; 
    border-color: #00d4aa;
    box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}
.form-row { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); 
    gap: 15px; 
    margin-bottom: 15px;
}

/* Badges */
.badge { 
    padding: 4px 10px; 
    border-radius: 12px; 
    font-size: 11px; 
    font-weight: 500;
    display: inline-block;
}
.badge-success { background: #d4edda; color: #155724; }
.badge-danger { background: #f8d7da; color: #721c24; }
.badge-warning { background: #fff3cd; color: #856404; }
.badge-info { background: #d1ecf1; color: #0c5460; }
.badge-secondary { background: #e9ecef; color: #495057; }
.badge-dark { background: #343a40; color: #fff; }

/* Tabs */
.tabs { 
    display: flex; 
    border-bottom: 2px solid #e1e4e8; 
    margin-bottom: 20px;
}
.tab { 
    padding: 12px 20px; 
    cursor: pointer; 
    border-bottom: 2px solid transparent; 
    margin-bottom: -2px; 
    font-weight: 500;
    color: #666;
    transition: all 0.2s;
}
.tab:hover { color: #00d4aa; }
.tab.active { 
    color: #00d4aa; 
    border-bottom-color: #00d4aa; 
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }

/* Modals */
.modal { 
    display: none; 
    position: fixed; 
    top: 0; 
    left: 0; 
    right: 0; 
    bottom: 0; 
    background: rgba(0,0,0,0.5); 
    z-index: 1000; 
    align-items: center; 
    justify-content: center;
    padding: 20px;
}
.modal.active { display: flex; }
.modal-content { 
    background: #fff; 
    border-radius: 8px; 
    width: 100%;
    max-width: 600px; 
    max-height: 90vh; 
    overflow-y: auto;
    animation: slideUp 0.3s;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-header { 
    padding: 20px; 
    border-bottom: 1px solid #e1e4e8; 
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}
.modal-header button {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}
.modal-body { padding: 20px; }
.modal-footer { 
    padding: 20px; 
    border-top: 1px solid #e1e4e8; 
    display: flex; 
    justify-content: flex-end; 
    gap: 10px;
}

/* Loading */
.loading { 
    display: inline-block; 
    width: 20px; 
    height: 20px; 
    border: 3px solid #f3f3f3; 
    border-top: 3px solid #00d4aa; 
    border-radius: 50%; 
    animation: spin 1s linear infinite; 
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Template loading overlay */
.loading-template {
    position: relative;
}

.loading-template::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-template::after {
    content: '⟳ Loading template...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 1001;
    font-weight: 500;
    color: #333;
}

/* Empty State */
.empty { 
    text-align: center; 
    padding: 60px 20px; 
    color: #666;
}
.empty i {
    font-size: 48px;
    color: #ddd;
    margin-bottom: 16px;
}

/* Campaign Filters - Desktop */
.campaign-filters-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.campaign-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.campaign-filters .filter-select {
    width: 150px;
    min-width: 120px;
}

.campaign-filters .filter-input {
    width: 120px;
    min-width: 100px;
}

.campaign-filters .filter-input-sm {
    width: 100px;
    min-width: 80px;
}

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

/* Bulk Action Bar */
.bulk-action-bar {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.bulk-action-bar span {
    font-weight: 600;
    color: #333;
}
.bulk-actions {
    display: flex;
    gap: 8px;
}

/* Checkbox Styling */
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #00d4aa;
}

/* Limits Display */
.limits-info {
    font-size: 11px;
    line-height: 1.5;
    color: #666;
    white-space: nowrap;
    min-width: 70px;
}
.limits-info .limit-row {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 1px;
}
.limits-info .limit-label {
    color: #888;
    min-width: 22px;
    font-size: 10px;
    font-weight: 500;
}
.limits-info .limit-value {
    font-weight: 600;
    color: #333;
    font-size: 11px;
}

/* Table column widths */
#campaigns-table th:nth-child(9),
#campaigns-table td:nth-child(9) {
    min-width: 80px;
    width: 80px;
}

/* Create Campaign Form Sections */
#create-campaign-modal .form-section {
    background: #fafafa;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
}

#create-campaign-modal .form-section h4 {
    margin: 0 0 15px 0;
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

#create-campaign-modal .form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

#create-campaign-modal .form-row:last-child {
    margin-bottom: 0;
}

#create-campaign-modal .form-group {
    flex: 1;
    min-width: 0;
}

#create-campaign-modal .form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 500;
    color: #444;
}

#create-campaign-modal .form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    transition: border-color 0.2s;
}

#create-campaign-modal .form-control:focus {
    border-color: #00d4aa;
    outline: none;
}

/* Multi-Select Dropdown Styles */
.multi-select-container {
    position: relative;
}

.multi-select-btn {
    width: 100%;
    text-align: left;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.2s;
}

.multi-select-btn:hover {
    border-color: #00d4aa;
}

.multi-select-btn:disabled {
    background: #f5f5f5;
    border-color: #ddd;
    cursor: not-allowed;
    opacity: 0.7;
}

.multi-select-btn.loading {
    background: #f5f5f5;
    cursor: wait;
}

.multi-select-btn.loading::after {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-top-color: #00d4aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

.loading-text {
    color: #999;
    font-style: italic;
}

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

.multi-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    margin-top: 2px;
}

.multi-select-options label {
    display: block;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 13px;
    transition: background 0.15s;
}

.multi-select-options label:hover {
    background: #f8f9fa;
}

.multi-select-options label:last-child {
    border-bottom: none;
}

.multi-select-options input[type="checkbox"] {
    margin-right: 8px;
    width: 16px;
    height: 16px;
    vertical-align: middle;
}

/* Progress Modal */
#bulk-progress-modal .modal-content {
    text-align: center;
}

#bulk-progress-fill {
    transition: width 0.3s ease;
}

#bulk-progress-stats strong {
    font-size: 16px;
}

/* View Campaign Sections */
.view-section {
    transition: all 0.2s ease;
}

.view-section:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    .view-section {
        grid-column: 1 / -1;
    }
}

/* User Stats Bar in Header */
#user-stats-bar {
    animation: fadeIn 0.3s ease;
    transition: all 0.3s ease;
}

#user-stats-bar:hover {
    background: #e9ecef !important;
    border-color: #dee2e6 !important;
}

#user-balance {
    color: #28a745;
    font-weight: 600;
}

#user-active-campaigns {
    color: #007bff;
    font-weight: 600;
}

/* Refresh Button Animation */
#refresh-stats-btn {
    transition: all 0.2s ease;
    border-radius: 4px;
}

#refresh-stats-btn:hover {
    background: #dee2e6;
    color: #333;
}

#refresh-stats-btn.spinning i {
    animation: spin 0.8s linear infinite;
}

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

/* ==================== MOBILE RESPONSIVE ==================== */

/* Mobile Menu Button - Additional Styles */
.mobile-menu-btn {
    background: none;
    border: none;
    cursor: pointer;
}

/* Tablet and below */
@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }
    
    .main {
        margin-left: 220px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app {
        flex-direction: column;
    }
    
    /* Sidebar mobile - using transform from inline styles */
    .sidebar {
        z-index: 1002 !important;
    }
    
    .sidebar-overlay {
        z-index: 1001 !important;
    }
    
    .main {
        margin-left: 0 !important;
        width: 100%;
    }
    
    .header {
        padding: 10px 15px;
        height: auto;
        min-height: 60px;
        flex-wrap: wrap;
        gap: 8px;
        position: sticky;
        top: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .header h2 {
        font-size: 14px;
        flex: 0 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    /* User stats bar mobile - Updated in inline styles */
    .user-stats-bar {
        /* Styles moved to inline CSS for better control */
    }
    
    .content {
        padding: 15px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Tables mobile */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -15px;
        padding: 0 15px;
    }
    
    table {
        min-width: 800px;
        font-size: 12px;
    }
    
    th, td {
        padding: 8px 10px;
    }
    
    /* Card header mobile */
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .card-header h3 {
        font-size: 14px;
    }
    
    /* Campaign filters mobile */
    .campaign-filters-header {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .campaign-filters {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    
    .campaign-filters .filter-select,
    .campaign-filters .filter-input,
    .campaign-filters .filter-input-sm {
        width: 100% !important;
        min-width: 0;
        font-size: 12px;
        padding: 6px 8px;
        height: 36px;
    }
    
    .campaign-filters .btn {
        padding: 6px 10px;
        font-size: 12px;
        height: 36px;
    }
    
    .campaign-filters button[title="Clear filters"] {
        grid-column: 1;
    }
    
    .campaign-filters button:last-child {
        grid-column: 2;
    }
    
    /* Form rows mobile */
    .form-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-group {
        min-width: 100% !important;
    }
    
    /* Form section mobile */
    #create-campaign-modal .form-section {
        padding: 12px;
    }
    
    #create-campaign-modal .form-section h4 {
        font-size: 11px;
    }
    
    /* Multi-select mobile */
    .multi-select-dropdown {
        max-height: 200px;
        position: fixed !important;
        left: 15px !important;
        right: 15px !important;
        top: auto !important;
        max-width: none;
    }
    
    /* Schedule days grid mobile */
    #campaign-schedule-days {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    
    #campaign-schedule-days label {
        padding: 6px 4px !important;
        font-size: 10px !important;
    }
    
    /* Bulk action bar mobile */
    .bulk-action-bar {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
        padding: 10px;
    }
    
    .bulk-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 6px;
    }
    
    .bulk-actions .btn {
        flex: 1;
        min-width: 80px;
        font-size: 11px;
        padding: 6px 10px;
    }
    
    /* Modal mobile */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 10px auto;
    }
    
    .modal-header h3 {
        font-size: 14px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    /* Checkbox in tables mobile */
    .campaign-checkbox {
        width: 20px;
        height: 20px;
    }
    
    /* Dropdown menu mobile */
    .dropdown-menu {
        position: fixed !important;
        left: 15px !important;
        right: 15px !important;
        top: auto !important;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .header {
        padding: 8px 10px;
    }
    
    .header h2 {
        font-size: 13px;
    }
    
    .mobile-menu-btn {
        width: 36px;
        height: 36px;
    }
    
    #user-stats-bar {
        font-size: 10px;
        padding: 3px 6px;
        gap: 4px;
    }
    
    #user-stats-bar span:not(#user-name-display):not(#user-balance):not(#user-active-campaigns):not(.stats-separator) {
        display: none;
    }
    
    .content {
        padding: 10px;
    }
    
    .btn {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .btn-sm {
        padding: 4px 6px;
        font-size: 10px;
    }
    
    /* Schedule days grid small mobile */
    #campaign-schedule-days {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Table actions mobile */
    .dropdown .btn {
        padding: 4px 8px;
        font-size: 11px;
    }
    
    /* Template preview mobile */
    #template-preview-content {
        font-size: 10px;
        padding: 8px;
    }
}

/* Dropdown Menu */
.dropdown-menu {
    animation: fadeIn 0.15s ease;
}
.dropdown-menu a:hover {
    background: #f5f5f5;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Template Preview */
#template-preview-content {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Template List */
.template-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}
.template-item:hover {
    background: #f8f9fa;
}
.template-item:last-child {
    border-bottom: none;
}
.template-item-info h4 {
    font-size: 14px;
    margin-bottom: 4px;
}
.template-item-info p {
    font-size: 12px;
    color: #888;
}
.template-item-actions {
    display: flex;
    gap: 8px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f1f1; }
::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
