/**
 * Abandoned Carts Dashboard Styles - Widescreen Layout
 * Updated to match abandoned bookings template styling
 *
 * @package ENNU\RetailShop
 */

.ennu-rs-abandoned-carts-dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;
    max-width: 100vw;
    padding: 16px;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Force full width in WordPress admin */
.ennu-rs-abandoned-carts-dashboard .dashboard-table {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

/* Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1a1a2e;
}

.dashboard-subtitle {
    margin: 2px 0 0;
    color: #6b7280;
    font-size: 13px;
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.btn-primary {
    background: #C9A962;
    color: #1A2744;
}

.btn-primary:hover {
    background: #B89952;
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
}

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

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

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

.btn-sm {
    padding: 5px 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* KPI Cards - Widescreen Flex Layout */
.kpi-cards {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.kpi-card {
    background: white;
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    border-left: 3px solid;
    min-width: 140px;
    flex: 1;
}

/* KPI Card Variants */
.kpi-card--total { border-left-color: #1A2744; }
.kpi-card--abandoned { border-left-color: #ef4444; }
.kpi-card--recovered { border-left-color: #10b981; }
.kpi-card--pending { border-left-color: #f59e0b; }
.kpi-card--revenue { border-left-color: #C9A962; }

.kpi-label {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    line-height: 1;
}

.kpi-trend {
    font-size: 11px;
    color: #6b7280;
    margin-top: 4px;
}

.kpi-trend.positive {
    color: #10b981;
}

.kpi-trend.negative {
    color: #ef4444;
}

/* Filters */
.dashboard-filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}

.filter-group select,
.filter-group input[type="search"] {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 5px;
    font-size: 13px;
    min-width: 130px;
}

.filter-group select:focus,
.filter-group input[type="search"]:focus {
    outline: none;
    border-color: #C9A962;
}

/* Loading */
.dashboard-loading {
    text-align: center;
    padding: 60px 20px;
}

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

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

/* Table - Widescreen Optimized */
.dashboard-table {
    overflow-x: auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.dashboard-table table {
    width: 100%;
    min-width: 1600px; /* Ensure all columns visible */
    border-collapse: collapse;
    font-size: 13px;
    table-layout: auto;
}

.dashboard-table th {
    background: #f9fafb;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.dashboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

.dashboard-table tbody tr:hover {
    background: #f9fafb;
}

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

/* Column Specific Widths - Widescreen */
.td-status { white-space: nowrap; min-width: 140px; }
.td-customer { min-width: 160px; }
.td-email { min-width: 180px; }
.td-phone { min-width: 120px; white-space: nowrap; }
.td-profile { min-width: 120px; white-space: nowrap; }
.td-products { min-width: 200px; }
.td-value { min-width: 90px; white-space: nowrap; }
.td-timeline { min-width: 220px; }
.td-source { min-width: 140px; }
.td-emails { min-width: 80px; }
.td-actions { min-width: 140px; white-space: nowrap; }

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.pending {
    background: #fef3c7;
    color: #d97706;
}

.status-badge.recovered {
    background: #d1fae5;
    color: #059669;
}

.status-badge.booked {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.expired {
    background: #f3f4f6;
    color: #6b7280;
}

/* Customer Badges */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 9px;
    font-weight: 600;
    margin-left: 4px;
}

.badge-customer {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-lead {
    background: #fef3c7;
    color: #d97706;
}

/* Customer Cell */
.customer-cell {
    display: flex;
    align-items: center;
    gap: 6px;
}

.customer-cell strong {
    color: #1f2937;
    font-size: 13px;
}

/* HubSpot Link */
.hubspot-link {
    color: #ff7a59;
    display: flex;
}

.hubspot-link:hover {
    opacity: 0.7;
}

/* Email & Phone Links */
.email-link {
    font-size: 12px;
    text-decoration: none;
    color: #6b7280;
}

.email-link:hover {
    color: #C9A962;
}

.phone-link {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    color: #059669;
}

.phone-link:hover {
    color: #047857;
}

/* Profile Links */
.profile-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    padding: 3px 8px;
    border-radius: 4px;
}

.profile-wp {
    background: #dbeafe;
    color: #1d4ed8;
}

.profile-wp:hover {
    background: #bfdbfe;
}

.profile-customer {
    background: #fce7f3;
    color: #be185d;
}

.profile-customer:hover {
    background: #fbcfe8;
}

/* Products List */
.products-list {
    font-size: 13px;
    line-height: 1.6;
    color: #374151;
}

.products-list small {
    color: #9ca3af;
}

/* Cart Value */
.cart-value {
    font-weight: 700;
    color: #059669;
    font-size: 14px;
}

/* Timeline */
.timeline {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.timeline-start {
    color: #6b7280;
}

.timeline-arrow {
    color: #d1d5db;
    font-weight: bold;
}

.timeline-end {
    color: #dc2626;
    font-weight: 500;
}

.timeline-duration {
    color: #9ca3af;
    font-weight: 400;
    margin-left: 2px;
}

/* Source Badges */
.source-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.source-paid { background: #fee2e2; color: #dc2626; }
.source-social { background: #fce7f3; color: #be185d; }
.source-organic { background: #d1fae5; color: #059669; }
.source-email { background: #dbeafe; color: #1d4ed8; }
.source-referral { background: #e0e7ff; color: #4338ca; }
.source-direct { background: #f3f4f6; color: #6b7280; }
.source-other { background: #f5f3ff; color: #C9A962; }

.source-page {
    font-size: 10px;
    color: #6b7280;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Email Dots */
.email-dots {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: nowrap;
}

.email-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #e5e7eb;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
}

.email-dot.sent {
    background: #10b981;
    color: white;
}

/* Email View Button */
.email-dot-view {
    background: none;
    border: none;
    padding: 2px 4px;
    margin-left: 2px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    color: #6b7280;
}

.email-dot-view:hover {
    opacity: 1;
    color: #374151;
}

.email-dot-view svg {
    display: block;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 6px;
}

.action-btn {
    padding: 5px 8px;
    font-size: 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 600;
}

.action-btn.resend {
    background: #dbeafe;
    color: #1d4ed8;
}

.action-btn.resend:hover {
    background: #bfdbfe;
}

.action-btn.delete {
    background: #fee2e2;
    color: #dc2626;
}

.action-btn.delete:hover {
    background: #fecaca;
}

/* Pagination */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    margin-top: 12px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.pagination-info {
    font-size: 12px;
    color: #6b7280;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-page {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    color: #374151;
}

.pagination-page:hover {
    background: #f9fafb;
}

.pagination-page.active {
    background: #C9A962;
    color: #1A2744;
    border-color: #C9A962;
    font-weight: 600;
}

/* Empty State */
.dashboard-empty {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.dashboard-empty h3 {
    margin: 0 0 10px;
    font-size: 20px;
    color: #1a1a2e;
}

.dashboard-empty p {
    margin: 0;
    font-size: 14px;
    color: #6b7280;
}

/* Muted Text */
.muted {
    color: #9ca3af;
    font-size: 13px;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 18px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    animation: slideIn 0.3s ease;
}

.toast--success {
    background: #10b981;
    color: white;
}

.toast--error {
    background: #ef4444;
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Email Preview Modal */
.email-preview-meta {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
}

.email-preview-body iframe {
    background: #ffffff;
    border: none;
    width: 100%;
    min-height: 400px;
}

/* Responsive Design - Widescreen First */
@media (max-width: 1200px) {
    .kpi-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .kpi-cards {
        grid-template-columns: repeat(2, 1fr);
    }

    .dashboard-table table {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .header-actions {
        width: 100%;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .kpi-cards {
        grid-template-columns: 1fr;
    }

    .dashboard-filters {
        flex-direction: column;
    }

    .filter-group select,
    .filter-group input[type="search"] {
        min-width: 100%;
        width: 100%;
    }

    .dashboard-table {
        overflow-x: auto;
    }

    .dashboard-table table {
        min-width: 1000px;
    }

    .table-pagination {
        flex-direction: column;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .ennu-rs-abandoned-carts-dashboard {
        padding: 12px;
    }

    .dashboard-header h1 {
        font-size: 20px;
    }

    .kpi-value {
        font-size: 20px;
    }
}

/* ==========================
   Unified Email Modal (Matches Email Logs)
   ========================== */

.ennu-email-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 39, 68, 0.9);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.15s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.ennu-email-modal {
    background: #fff;
    border-radius: 12px;
    max-width: 1400px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    animation: slideUp 0.2s ease-out;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.ennu-email-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    border-bottom: 2px solid #C9A962;
    background: linear-gradient(135deg, #1A2744 0%, #2d3a52 100%);
    border-radius: 12px 12px 0 0;
    flex-shrink: 0;
}

.ennu-email-modal-header h3 {
    margin: 0;
    color: #C9A962;
    font-size: 1.25rem;
    font-weight: 700;
}

.ennu-email-modal .modal-close {
    font-size: 32px;
    color: #C9A962;
    text-decoration: none;
    line-height: 1;
    opacity: 0.9;
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.ennu-email-modal .modal-close:hover {
    opacity: 1;
    color: #fff;
    transform: scale(1.1);
}

.ennu-email-modal-body {
    padding: 0;
    overflow: hidden;
    flex: 1;
    display: flex;
    min-height: 0;
}

/* Two Column Layout for Desktop */
@media (min-width: 992px) {
    .ennu-email-modal-body {
        flex-direction: row;
    }
    .email-meta-column {
        width: 380px;
        flex-shrink: 0;
        padding: 24px;
        overflow-y: auto;
        border-right: 2px solid #e5e7eb;
        background: #FAF8F5;
    }
    .email-content-column {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        background: #fff;
    }
    .email-content-section {
        flex: 1;
        display: flex;
        flex-direction: column;
        padding: 20px;
        overflow: hidden;
    }
    .email-content-section h4 {
        color: #1A2744;
        font-size: 1rem;
        margin: 0 0 12px 0;
        padding-bottom: 8px;
        border-bottom: 2px solid #C9A962;
        flex-shrink: 0;
    }
    .email-content-frame {
        flex: 1;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff;
        overflow: auto;
        min-height: 0;
    }
    .email-html-preview {
        width: 100%;
        height: 100%;
        min-height: 500px;
        border: none;
        background: #fff;
    }
}

/* Mobile/Tablet Layout */
@media (max-width: 991px) {
    .ennu-email-modal-body {
        flex-direction: column;
        overflow-y: auto;
        padding: 24px;
    }
    .email-meta-column {
        width: 100%;
        margin-bottom: 20px;
    }
    .email-content-column {
        width: 100%;
    }
    .email-content-frame {
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff;
        min-height: 300px;
        max-height: 500px;
        overflow: auto;
    }
    .email-html-preview {
        width: 100%;
        min-height: 300px;
        border: none;
        background: #fff;
    }
}

.email-meta {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}

.meta-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.meta-row:last-child {
    border-bottom: none;
}

.meta-label {
    font-weight: 700;
    color: #1A2744;
    min-width: 90px;
    font-size: 0.85rem;
}

.meta-value {
    color: #4b5563;
    word-break: break-word;
    font-size: 0.875rem;
}

.ennu-email-modal-footer {
    padding: 16px 24px;
    border-top: 2px solid #C9A962;
    text-align: right;
    background: #FAF8F5;
    flex-shrink: 0;
}

.ennu-email-modal .btn-close {
    display: inline-block;
    padding: 10px 28px;
    background: #1A2744;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border: none;
    cursor: pointer;
}

.ennu-email-modal .btn-close:hover {
    background: #C9A962;
    color: #1A2744;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.email-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    text-align: center;
    min-height: 400px;
    width: 100%;
}

.email-error-state .error-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.email-error-state h3 {
    margin: 0 0 12px;
    font-size: 1.5rem;
    color: #1A2744;
}

.email-error-state p {
    margin: 0 0 24px;
    color: #6b7280;
    font-size: 1rem;
}
