/**
 * Retrieve Emails Page Styles
 * 
 * Converted from React/Tailwind design to WordPress-compatible CSS
 * Maintains pixel-perfect design fidelity from original React implementation
 */

/* CSS Variables - Using theme color system (HSL format without hsl() wrapper) */
.bc-audit-retrieve-emails-wrapper {
    --retrieve-bg: 240 15% 6%;
    --retrieve-foreground: 210 40% 98%;
    --retrieve-card: 240 15% 9%;
    --retrieve-card-foreground: 210 40% 98%;
    --retrieve-primary: 300 76% 60%;
    --retrieve-primary-foreground: 240 15% 6%;
    --retrieve-muted: 240 20% 12%;
    --retrieve-muted-foreground: 215 20% 65%;
    --retrieve-border: 240 20% 18%;
    --retrieve-destructive: 0 84% 60%;
    --retrieve-destructive-foreground: 210 40% 98%;
    --retrieve-ring: 300 76% 60%;
    --retrieve-radius: 0.75rem;
    
    /* Gradient colors (hex format for gradients) */
    --retrieve-violet-600: #7c3aed;
    --retrieve-purple-500: #a855f7;
    --retrieve-green-600: #22c163;
    --retrieve-green-100: #dcfce7;
    --retrieve-green-400: #4ade80;
    --retrieve-green-900-30: rgba(20, 83, 45, 0.3);
}

/* Main Wrapper */
.bc-audit-retrieve-emails-wrapper {
    flex: 1 1 0%;
    padding: 1.5rem;
    overflow: auto;
    font-family: 'DM Sans', system-ui, sans-serif;
    background-color: hsl(var(--retrieve-bg));
    color: hsl(var(--retrieve-foreground));
}

@media (min-width: 768px) {
    .bc-audit-retrieve-emails-wrapper {
        padding: 2rem;
    }
}

/* Container */
.retrieve-emails-container {
    width: 100%;
    margin: 0 auto;
}

.retrieve-emails-content {
    max-width: 56rem; /* max-w-4xl */
    margin-left: auto;
    margin-right: auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header Section */
.retrieve-emails-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.retrieve-emails-title {
    font-size: 1.875rem;
    line-height: 2.25rem;
    font-weight: 700;
    color: hsl(var(--retrieve-foreground));
    margin: 0;
}

@media (min-width: 768px) {
    .retrieve-emails-title {
        font-size: 2.25rem;
        line-height: 2.5rem;
    }
}

.emails-summary {
    background-color: hsl(var(--retrieve-muted) / 0.5);
    border-radius: var(--retrieve-radius);
    padding: 0.75rem 1.5rem;
    display: inline-block;
    margin: 0 auto;
}

.emails-summary-text {
    color: hsl(var(--retrieve-muted-foreground));
    margin: 0;
    font-size: 1rem;
    line-height: 1.5rem;
}

.emails-summary-text .text-primary {
    color: hsl(var(--retrieve-primary));
    font-weight: 600;
}

/* Campaigns Container */
.retrieve-emails-campaigns {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Campaign Section */
.email-campaign {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Campaign Header - Gradient Background */
.campaign-header {
    background: linear-gradient(to right, var(--retrieve-violet-600), var(--retrieve-purple-500));
    border-top-left-radius: 1rem;
    border-top-right-radius: 1rem;
    padding: 1.5rem;
}

.campaign-title {
    font-size: 1.25rem;
    line-height: 1.75rem;
    font-weight: 700;
    color: white;
    margin: 0 0 1rem 0;
}

@media (min-width: 768px) {
    .campaign-title {
        font-size: 1.5rem;
        line-height: 2rem;
    }
}

.campaign-info {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.campaign-badge {
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: white;
    padding: 0.375rem 1rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
}

/* Campaign Emails Container */
.campaign-emails {
    background-color: hsl(var(--retrieve-card));
    border: 1px solid hsl(var(--retrieve-border));
    border-top: 0;
    border-bottom-left-radius: 1rem;
    border-bottom-right-radius: 1rem;
    display: flex;
    flex-direction: column;
}

.campaign-emails > .email-item:not(:last-child) {
    border-bottom: 1px solid hsl(var(--retrieve-border));
}

/* Email Item */
.email-item {
    padding: 1.5rem;
}

/* Email Header */
.email-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.email-title-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.email-title {
    font-size: 1.125rem;
    line-height: 1.75rem;
    font-weight: 600;
    color: hsl(var(--retrieve-primary));
    margin: 0;
}

.email-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.email-time {
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: hsl(var(--retrieve-muted-foreground));
    background-color: hsl(var(--retrieve-muted));
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
}

.email-label {
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--retrieve-green-600);
    background-color: var(--retrieve-green-100);
    padding: 0.25rem 0.75rem;
    border-radius: 0.25rem;
    font-weight: 500;
}

/* Dark mode support for email label */
@media (prefers-color-scheme: dark) {
    .email-label {
        background-color: var(--retrieve-green-900-30);
        color: var(--retrieve-green-400);
    }
}

/* Delete Button */
.delete-email-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: var(--retrieve-radius);
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    background: transparent;
    cursor: pointer;
    width: 2.5rem;
    height: 2.5rem;
    color: hsl(var(--retrieve-muted-foreground));
    padding: 0;
    flex-shrink: 0;
}

.delete-email-btn:focus-visible {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px hsl(var(--retrieve-ring)), 0 0 0 4px hsl(var(--retrieve-bg));
}

.delete-email-btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}

.delete-email-btn:hover,
.delete-email-btn:focus,
.delete-email-btn:focus-visible {
    color: hsl(var(--retrieve-destructive));
    background-color: hsl(var(--retrieve-destructive) / 0.1);
}

.delete-email-btn:active {
    color: hsl(var(--retrieve-destructive));
    background-color: hsl(var(--retrieve-destructive) / 0.2);
}

.delete-icon-svg {
    pointer-events: none;
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    stroke: currentColor;
    transition: stroke 0.3s;
}

/* Ensure icon turns red on hover and focus */
.delete-email-btn:hover .delete-icon-svg,
.delete-email-btn:focus .delete-icon-svg,
.delete-email-btn:focus-visible .delete-icon-svg {
    stroke: hsl(var(--retrieve-destructive));
    color: hsl(var(--retrieve-destructive));
}

.delete-email-btn:active .delete-icon-svg {
    stroke: hsl(var(--retrieve-destructive));
    color: hsl(var(--retrieve-destructive));
}

/* Email Subject */
.email-subject {
    margin-bottom: 1rem;
    border-left: 4px solid hsl(var(--retrieve-primary));
    background-color: hsl(var(--retrieve-muted) / 0.3);
    padding: 1rem;
    border-top-right-radius: var(--retrieve-radius);
    border-bottom-right-radius: var(--retrieve-radius);
}

.email-subject-label {
    font-weight: 600;
    color: hsl(var(--retrieve-foreground));
}

.email-subject-text {
    color: hsl(var(--retrieve-foreground));
}

/* Email Content Section */
.email-content-section {
    margin-top: 0;
}

.email-content-label {
    font-weight: 600;
    color: hsl(var(--retrieve-foreground));
    margin-bottom: 0.5rem;
    display: block;
}

.email-content {
    background-color: hsl(var(--retrieve-muted) / 0.3);
    padding: 1rem;
    border-radius: var(--retrieve-radius);
}

.email-content-text {
    background-color: transparent;
    background-image: none;
    border-bottom-left-radius: 10px;
    border-bottom-right-radius: 10px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    box-sizing: border-box;
    color: hsl(var(--retrieve-muted-foreground));
    display: block;
    font-family: "DM Sans", system-ui, sans-serif;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    height: auto;
    line-height: 22.75px;
    margin-bottom: 0px;
    margin-left: 0px;
    margin-right: 0px;
    margin-top: 8px;
    overflow-wrap: break-word;
    padding-bottom: 12px;
    padding-left: 12px;
    padding-right: 12px;
    padding-top: 12px;
    text-align: start;
    text-size-adjust: 100%;
    text-wrap-mode: wrap;
    unicode-bidi: isolate;
    white-space-collapse: preserve;
    white-space: pre-line;
    width: 100%;
    -webkit-font-smoothing: antialiased;
}

.email-content-text strong {
    font-weight: 600;
    color: hsl(var(--retrieve-foreground));
}

/* Company Data */
.email-company-data {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid hsl(var(--retrieve-border));
    color: hsl(var(--retrieve-foreground));
    font-size: 0.875rem;
}

.email-company-data strong {
    font-weight: 600;
    color: hsl(var(--retrieve-foreground));
}

/* Toast Notifications - Explicit styles for visibility (toast is appended to body, outside wrapper) */
.toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 400px;
    pointer-events: none;
}

.toast-container .toast {
    pointer-events: auto;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: 0.75rem;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1);
    opacity: 0;
    transform: translateX(100%);
    transition: opacity 0.3s, transform 0.3s;
    min-width: 300px;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.success {
    border-left: 4px solid #22c163;
    background-color: #f0fdf4;
}

.toast.success .toast-message {
    color: #166534;
}

.toast.error {
    border-left: 4px solid #ef4444;
    background-color: #fef2f2;
}

.toast.error .toast-message {
    color: #991b1b;
}

.toast-message {
    flex: 1;
    color: #1f2937;
    font-size: 0.9375rem;
    font-weight: 500;
}

.toast-close {
    background: transparent;
    border: none;
    color: #6b7280;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem;
    transition: background-color 0.2s, color 0.2s;
}

.toast-close:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: #1f2937;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
    .bc-audit-retrieve-emails-wrapper {
        padding: 1rem;
    }
    
    .retrieve-emails-content {
        gap: 1.5rem;
    }
    
    .campaign-header {
        padding: 1rem;
    }
    
    .email-item {
        padding: 1rem;
    }
    
    .email-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .delete-email-btn {
        align-self: flex-end;
    }
    
    .campaign-info {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .toast-container {
        top: 4rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    .toast {
        min-width: auto;
        width: 100%;
    }
}

/* Loading State */
.delete-email-btn:disabled .delete-icon-svg {
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.bc-audit-retrieve-emails-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 3rem 1.5rem;
}

.retrieve-emails-empty-state {
    text-align: center;
    max-width: 420px;
}

.retrieve-emails-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    margin: 0 auto 1.75rem;
    background: linear-gradient(135deg, hsl(var(--retrieve-muted)) 0%, hsl(var(--retrieve-border)) 100%);
    border: 1px solid hsl(var(--retrieve-border));
    border-radius: 1.5rem;
    color: hsl(var(--retrieve-primary));
    box-shadow: 0 0 0 1px rgba(168, 85, 247, 0.1), 0 20px 40px -12px rgba(0, 0, 0, 0.4);
}

.retrieve-emails-empty-icon svg {
    opacity: 0.9;
}

.retrieve-emails-empty-headline {
    font-size: 1.75rem;
    font-weight: 700;
    color: hsl(var(--retrieve-foreground));
    margin: 0 0 0.75rem !important;
    letter-spacing: -0.02em;
}

.retrieve-emails-empty-subtext {
    font-size: 1rem;
    line-height: 1.6;
    color: hsl(var(--retrieve-muted-foreground));
    margin: 0 0 2rem;
}

.retrieve-emails-empty-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: hsl(var(--retrieve-primary-foreground));
    background: linear-gradient(135deg, var(--retrieve-violet-600), var(--retrieve-purple-500));
    border: none;
    border-radius: 0.75rem;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 14px -2px rgba(124, 58, 237, 0.4);
}

.retrieve-emails-empty-cta:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px -4px rgba(124, 58, 237, 0.5);
}

.retrieve-emails-empty-cta:active {
    transform: translateY(0);
}

.retrieve-emails-empty-cta svg {
    flex-shrink: 0;
}

