/**
 * SMS Campaign Manager - Main Stylesheet
 * 
 * Organization:
 * 1. CSS Reset & Base Styles
 * 2. Layout & Structure
 * 3. Typography
 * 4. Buttons & Forms
 * 5. Tables
 * 6. Badges & Status Indicators
 * 7. Modals
 * 8. Alerts & Messages
 * 9. Loading & Empty States
 * 10. Page-Specific Styles
 * 11. Utility Classes
 * 12. Animations
 */

/* ==========================================
   1. CSS RESET & BASE STYLES
   ========================================== */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Login page specific background */
body.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ==========================================
   2. LAYOUT & STRUCTURE
   ========================================== */

.header {
    background: white;
    border-bottom: 1px solid #e0e0e0;
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header h1 {
    color: #333;
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-info {
    color: #666;
    font-size: 14px;
}

.container {
    max-width: 1400px;
    margin: 30px auto;
    padding: 0 30px;
}

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

.page-header h2 {
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.card {
    background: white;
    border-radius: 10px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.card h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #f0f0f0;
}

/* ==========================================
   3. TYPOGRAPHY
   ========================================== */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: #333;
}

small {
    font-size: 12px;
    color: #666;
}

code {
    background: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ==========================================
   4. BUTTONS & FORMS
   ========================================== */

/* Buttons */
.btn {
    padding: 10px 20px;
    background: #667eea;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    display: inline-block;
    transition: all 0.2s ease;
}

.btn:hover {
    background: #5568d3;
}

.btn:active {
    transform: translateY(1px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
}

.btn-danger:hover {
    background: #c82333;
}

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

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    color: #666;
    margin-top: 5px;
    font-size: 12px;
}

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

/* ==========================================
   5. TABLES
   ========================================== */

.table-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

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

thead {
    background: #f8f9fa;
}

th {
    padding: 12px 15px;
    text-align: left;
    color: #666;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background: #f8f9fa;
}

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

.filters-table thead {
    background: #f8f9fa;
}

.filters-table th {
    padding: 12px 15px;
    text-align: left;
    color: #666;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
}

.filters-table td {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
}

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

/* ==========================================
   6. BADGES & STATUS INDICATORS
   ========================================== */

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

/* Status badges */
.badge-draft {
    background: #e2e3e5;
    color: #383d41;
}

.badge-ready {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-sending {
    background: #fff3cd;
    color: #856404;
}

.badge-completed {
    background: #d4edda;
    color: #155724;
}

.badge-paused {
    background: #f8d7da;
    color: #721c24;
}

.badge-cancelled {
    background: #f8d7da;
    color: #721c24;
}

/* Generic badges */
.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-primary {
    background: #e7f3ff;
    color: #0066cc;
}

.badge-global {
    background: #d4edda;
    color: #155724;
}

.badge-brand {
    background: #d1ecf1;
    color: #0c5460;
}

/* ==========================================
   7. MODALS
   ========================================== */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow-y: auto;
}

.modal.show {
    display: block;
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 0;
    width: 90%;
    max-width: 800px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #333;
}

.close {
    color: #999;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
    text-align: right;
}

/* ==========================================
   8. ALERTS & MESSAGES
   ========================================== */

.alert {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
}

.alert-success {
    background: #d4edda;
    color: #155724;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
}

.error-message {
    background: #fee;
    color: #c33;
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
    display: none;
}

.error-message.show {
    display: block;
}

/* ==========================================
   9. LOADING & EMPTY STATES
   ========================================== */

.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading.show {
    display: block;
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state h3 {
    font-size: 20px;
    margin-bottom: 10px;
    color: #999;
}

.empty-state p {
    color: #999;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-overlay.show {
    display: flex;
}

.loading-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* ==========================================
   10. PAGE-SPECIFIC STYLES
   ========================================== */

/* Login Page */
.login-container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: #333;
    font-size: 24px;
    margin-bottom: 10px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

/* Dashboard */
.welcome-box {
    background: white;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.welcome-box h2 {
    color: #333;
    font-size: 28px;
    margin-bottom: 15px;
}

.welcome-box p {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.action-card {
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s;
}

.action-card:hover {
    border-color: #667eea;
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.2);
}

.action-card h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 10px;
    border-bottom: none;
    padding-bottom: 0;
}

.action-card p {
    color: #666;
    font-size: 14px;
}

.action-card.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Filters */
.filters {
    background: white;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    display: flex;
    gap: 15px;
    align-items: end;
}

.filter-group {
    flex: 1;
}

.filter-group label {
    display: block;
    color: #666;
    font-size: 13px;
    margin-bottom: 5px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.filter-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.filters-container {
    background: white;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* Campaign Creation */
.stats-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    text-align: center;
}

.stats-box .label {
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.stats-box .value {
    color: #333;
    font-size: 24px;
    font-weight: 600;
}

.message-preview {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #667eea;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    min-height: 100px;
}

.char-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-top: 10px;
}

.char-counter.warning {
    background: #fff3cd;
}

.char-counter.danger {
    background: #f8d7da;
}

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.token {
    background: #e7f3ff;
    color: #0066cc;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-family: 'Courier New', monospace;
}

.token:hover {
    background: #cce5ff;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
}

.tab.active {
    border-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.tab:hover {
    border-color: #667eea;
}

/* Brand Info */
.brand-info {
    background: white;
    border-radius: 10px;
    padding: 20px 25px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.brand-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.brand-info-item label {
    display: block;
    color: #666;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 5px;
}

.brand-info-item .value {
    color: #333;
    font-size: 15px;
    font-weight: 500;
}

/* Filter Options */
.detected-values {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-top: 15px;
    max-height: 200px;
    overflow-y: auto;
}

.detected-values h4 {
    font-size: 13px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.value-item {
    padding: 8px 10px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.value-item .count {
    color: #666;
}

.option-group {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 15px;
    position: relative;
}

.option-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.option-group-header h4 {
    font-size: 14px;
    color: #333;
}

.db-values-container {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
}

.db-value-tag {
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.db-value-tag .remove {
    cursor: pointer;
    color: #999;
    font-weight: bold;
}

.db-value-tag .remove:hover {
    color: #dc3545;
}

/* ==========================================
   11. UTILITY CLASSES
   ========================================== */

.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.hidden {
    display: none;
}

.visible {
    display: block;
}

/* ==========================================
   12. ANIMATIONS
   ========================================== */

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Fade in */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Slide down */
@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .action-grid {
        grid-template-columns: 1fr;
    }
    
    .brand-info-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .brand-info-grid {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
}

