/* ============================================
   CRM MODULE STYLES - THODA CHANNEL MANAGER
   /backoffice/css/crm.css
   ============================================ */

/* ============================================
   CONTAINER & HEADER
   ============================================ */
.crm-container {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

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

.crm-title h2 {
    margin: 0 0 4px 0;
    font-size: 24px;
    color: #1a1a2e;
}

.crm-title p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

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

/* ============================================
   STATS CARDS
   ============================================ */
.crm-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.stat-icon {
    font-size: 32px;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a2e;
    line-height: 1;
}

.stat-label {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
}

/* ============================================
   TABS
   ============================================ */
.crm-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 24px;
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: #667eea;
    background: #f8f9ff;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: #f8f9ff;
}

.tab-content {
    display: none;
}

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

/* ============================================
   FILTERS & SEARCH
   ============================================ */
.crm-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 250px;
}

.search-box input {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-group select {
    padding: 10px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* ============================================
   TABLE
   ============================================ */
.crm-table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

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

.crm-table th {
    background: #f8f9fa;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #555;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    white-space: nowrap;
}

.crm-table th:hover {
    background: #eef0f2;
}

.crm-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
    color: #333;
}

.crm-table tr:hover {
    background: #f8f9ff;
}

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

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

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* Contact row styles */
.contact-name {
    display: flex;
    align-items: center;
    gap: 10px;
}

.contact-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.contact-info {
    display: flex;
    flex-direction: column;
}

.contact-fullname {
    font-weight: 500;
    color: #1a1a2e;
}

.contact-tags {
    font-size: 11px;
    color: #888;
}

.vip-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.vip-platinum {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.vip-gold {
    background: linear-gradient(135deg, #f5af19 0%, #f12711 100%);
    color: white;
}

.vip-silver {
    background: linear-gradient(135deg, #bdc3c7 0%, #2c3e50 100%);
    color: white;
}

.vip-standard {
    background: #e0e0e0;
    color: #666;
}

.marketing-icons {
    display: flex;
    gap: 4px;
}

.marketing-icon {
    opacity: 0.3;
}

.marketing-icon.active {
    opacity: 1;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    background: #f0f0f0;
}

.btn-icon:hover {
    background: #667eea;
    color: white;
}

.btn-icon.btn-danger:hover {
    background: #e74c3c;
}

/* ============================================
   PAGINATION
   ============================================ */
.crm-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.crm-pagination button {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.crm-pagination button:hover:not(:disabled) {
    border-color: #667eea;
    color: #667eea;
}

.crm-pagination button.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.crm-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   BULK ACTIONS
   ============================================ */
.bulk-actions {
    background: #1a1a2e;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 16px;
}

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

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

.automations-header h3 {
    margin: 0;
}

.automations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.automation-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #667eea;
}

.automation-card.inactive {
    border-left-color: #ccc;
    opacity: 0.7;
}

.automation-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.automation-name {
    font-weight: 600;
    font-size: 16px;
    color: #1a1a2e;
}

.automation-trigger {
    font-size: 12px;
    color: #666;
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
}

.automation-details {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
}

.automation-stats {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
}

.automation-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #667eea;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.automation-templates {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
}

.automation-templates h4 {
    margin: 0 0 16px 0;
    color: #555;
}

.template-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

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

.campaigns-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.campaign-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.campaign-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
}

.campaign-meta {
    font-size: 13px;
    color: #666;
}

.campaign-status {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-draft {
    background: #f0f0f0;
    color: #666;
}

.status-scheduled {
    background: #fff3cd;
    color: #856404;
}

.status-sending {
    background: #cce5ff;
    color: #004085;
}

.status-sent {
    background: #d4edda;
    color: #155724;
}

/* ============================================
   SETTINGS / FORMS
   ============================================ */
.settings-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 800px;
}

.settings-section h3 {
    margin: 0 0 8px 0;
}

.settings-description {
    color: #666;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    font-size: 14px;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group small {
    font-size: 12px;
    color: #888;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e0e0e0;
}

.consents-group {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 8px;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.smtp-status {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
}

.smtp-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.smtp-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ============================================
   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;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-content.modal-large {
    max-width: 800px;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: #333;
}

.modal-body {
    padding: 24px;
}

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

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
}

.btn-outline {
    background: transparent;
    border: 1px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

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

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

/* ============================================
   CONTACT DETAIL MODAL
   ============================================ */
.contact-detail {
    display: grid;
    gap: 24px;
}

.contact-detail-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.contact-detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 28px;
}

.contact-detail-info h3 {
    margin: 0 0 8px 0;
}

.contact-detail-meta {
    color: #666;
    font-size: 14px;
}

.contact-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.contact-stat {
    text-align: center;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 8px;
}

.contact-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

.contact-stat-label {
    font-size: 12px;
    color: #666;
}

.contact-bookings {
    margin-top: 16px;
}

.contact-bookings h4 {
    margin: 0 0 12px 0;
}

.booking-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.booking-item {
    display: flex;
    justify-content: space-between;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .crm-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .crm-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .crm-tabs {
        overflow-x: auto;
    }
    
    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .crm-filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-group select {
        flex: 1;
    }
    
    .crm-table-container {
        overflow-x: auto;
    }
    
    .contact-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   EMPTY STATES
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h4 {
    margin: 0 0 8px 0;
    color: #333;
}

.empty-state p {
    margin: 0 0 20px 0;
}