/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    margin-top: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
}

header h1 {
    color: #2c3e50;
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    color: #7f8c8d;
    font-size: 1.1em;
}

/* Database Status Banner */
.db-status-banner {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 12px 16px;
    transition: all 0.3s ease;
}

.db-status-banner.connected {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #b8dadb;
}

.db-status-banner.disconnected {
    background: linear-gradient(135deg, #f8d7da 0%, #f1b0b7 100%);
    border-color: #f5c2c7;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

#statusIcon {
    font-size: 16px;
    min-width: 20px;
}

#statusText {
    flex: 1;
    font-weight: 500;
}

#refreshStatus {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

#refreshStatus:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.db-status-banner.connected #statusIcon {
    color: #155724;
}

.db-status-banner.disconnected #statusIcon {
    color: #721c24;
}

.db-status-banner.checking #statusIcon {
    color: #856404;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 30px;
}

.tab-button {
    flex: 1;
    padding: 15px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 500;
    color: #7f8c8d;
    transition: all 0.3s ease;
}

.tab-button:hover {
    background-color: #f8f9fa;
    color: #2c3e50;
}

.tab-button.active {
    color: #3498db;
    border-bottom: 3px solid #3498db;
    background-color: #f8f9fa;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form Elements */
.upload-section, .compose-section, .responses-section, .batches-section {
    margin-bottom: 30px;
}

.file-upload, .batch-info, .batch-selector, .message-composer, .send-options {
    margin-bottom: 20px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
}

input[type="text"], input[type="file"], select, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 5px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus, select:focus, textarea:focus {
    border-color: #3498db;
    outline: none;
}

/* Buttons */
button {
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.save-btn, .send-btn {
    background-color: #27ae60;
    color: white;
}

.save-btn:hover, .send-btn:hover {
    background-color: #219a52;
}

.clear-btn, .stop-btn {
    background-color: #e74c3c;
    color: white;
}

.clear-btn:hover, .stop-btn:hover {
    background-color: #c0392b;
}

/* Tables */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: white;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

th {
    background-color: #3498db;
    color: white;
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:hover {
    background-color: #f8f9fa;
}

/* Status indicators */
.status-valid {
    color: #27ae60;
    font-weight: 600;
}

.status-invalid {
    color: #e74c3c;
    font-weight: 600;
}

.badge {
    background: #28a745;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 0.8em;
    font-weight: normal;
}

.edit-input {
    width: 100%;
    border: 1px solid #ddd;
    padding: 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.edit-input:focus {
    border-color: #007bff;
    outline: none;
    box-shadow: 0 0 0 2px rgba(0,123,255,.25);
}

.filter-btn {
    padding: 5px 12px;
    border: 1px solid #ddd;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: all 0.2s;
}

.filter-btn:hover {
    background: #e9ecef;
}

.filter-btn.active {
    background: #007bff;
    color: white;
    border-color: #007bff;
}

.contact-row-hidden {
    display: none !important;
}

/* Stats */
.stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 5px;
}

.stats span {
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 3px;
}

#totalContacts {
    background-color: #3498db;
    color: white;
}

#validContacts {
    background-color: #27ae60;
    color: white;
}

#invalidContacts {
    background-color: #e74c3c;
    color: white;
}

/* Character count */
.char-count {
    text-align: right;
    font-size: 0.9em;
    color: #7f8c8d;
    margin-top: 5px;
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 20px;
    background-color: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background-color: #3498db;
    width: 0%;
    transition: width 0.3s ease;
}

/* Rate limit info */
.rate-limit-info {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 20px;
}

.rate-limit-info p {
    margin-bottom: 10px;
    color: #856404;
}

/* Actions */
.actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

/* Filters */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
}

/* Preview section */
.preview-section {
    margin-top: 30px;
    padding: 20px;
    border: 2px solid #3498db;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.preview-section h3 {
    color: #2c3e50;
    margin-bottom: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        margin: 10px;
        padding: 15px;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab-button {
        border-bottom: 1px solid #e0e0e0;
    }
    
    .actions {
        flex-direction: column;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}