/**
 * Email Results Display Styles (Phase 2)
 * Separated from main analyzer styles for cleaner organization
 */

/* ========================================
   RESULTS CONTAINER
   ======================================== */

.mailauth-results-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========================================
   RESULTS HEADER
   ======================================== */

.mailauth-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    background: #ffffff;
    border-radius: 4px;
    margin-bottom: 20px;
    box-shadow: 0 0 13px 0 rgba(82, 63, 105, 0.05);
}

.btn-back-to-analyzer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #F2F3F8;
    border: none;
    border-radius: 4px;
    color: #646C9A;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-back-to-analyzer:hover {
    background: #EBEDF2;
    color: #2c3e50;
}

.mailauth-email-display {
    font-size: 18px;
    font-weight: 600;
    color: #646C9A;
}

.error-info-container {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.error-status.has-errors h4 {
    color: #E74C3C;
    margin: 0;
}

.error-status.no-errors h4 {
    color: #60D3B1;
    margin: 0;
}

.mail-auth-info-icon {
    cursor: pointer;
}

/* ========================================
   ERRORS SECTION
   ======================================== */

.mailauth-errors-section {
    margin-bottom: 20px;
}

.mailauth-errors-section.hide {
    display: none;
}

.mailauth-card {
    background: #ffffff;
    border-radius: 4px;
    padding: 25px;
    box-shadow: 0 0 13px 0 rgba(82, 63, 105, 0.05);
}

.errors-title {
    color: #E74C3C;
    margin-bottom: 16px;
}

.errors-list {
    list-style: none;
    padding-left: 0;
    margin-bottom: 20px;
}

.errors-list li {
    padding: 8px 0;
    color: #646C9A;
    font-size: 14px;
}

.errors-list b {
    color: #2c3e50;
}

.errors-note {
    padding: 16px;
    background: #F2F3F8;
    border-radius: 4px;
    color: #646C9A;
    font-size: 14px;
}

.errors-note code {
    background: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    color: #5867DD;
    font-family: 'Courier New', monospace;
}

/* ========================================
   RESULTS GRID
   ======================================== */

.mailauth-results-grid {
    display: grid;
    grid-template-columns: 5fr 7fr;
    gap: 20px;
    margin-bottom: 20px;
}

#spf-lookup-value {
    color: #4875F4;
}

.item .text-primary {
    color: #4875F4 !important;
}

#spf-alignment-mode-value,
#dkim-alignment-mode-value,
#subject-value {
    color: #646c9a;
}

.from-address-value,
.return-path-value,
.date-received-value {
    color: #646c9a;
    font-size: 13px;
}

/* ========================================
   COMPLIANCE CARD
   ======================================== */

.compliance-card {
    height: 100%;
}

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

.compliance-text {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.badge {
    padding: 6px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #E8FFF3;
    color: #34BFA3;
}

.badge-danger {
    background: #FFE8E8;
    color: #E74C3C;
}

.badge-warning {
    background: #FFF8E8;
    color: #FFB822;
}

/* Compliance Chart */
.compliance-chart-container {
    max-width: 440px;
    margin: 0 auto 30px;
}

.compliance-chart {
    width: 100%;
    height: auto;
}

.compliance-label {
    background: #ffffff;
    border: 1px solid #EBEDF2;
    border-radius: 6px;
    padding: 12px;
    height: 100%;
}

.label-title {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.label-description {
    font-size: 12px;
    color: #646C9A;
    line-height: 1.4;
}

/* Compliance Legend */
.compliance-legend {
    display: flex;
    justify-content: space-around;
    gap: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-text {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #646C9A;
}

.info-icon {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.info-icon:hover {
    opacity: 1;
}

/* ========================================
   EMAIL INFO CARD
   ======================================== */

.email-info-card {
    margin-bottom: 20px;
}

.email-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.info-item {
    display: flex;
    gap: 12px;
}

.info-item .info-icon {
    flex-shrink: 0;
    opacity: 0.8;
}

.info-content {
    flex: 1;
    min-width: 0;
}

.info-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #646C9A;
    margin-bottom: 6px;
}

.info-value {
    font-size: 14px;
    color: #2c3e50;
    font-weight: 500;
    word-break: break-all;
}

/* ========================================
   DETAILS GRID
   ======================================== */

.details-grid {
    display: grid;
    grid-template-columns: 7fr 5fr;
    gap: 20px;
}

/* Details Card */
.details-card {
    height: 100%;
}

.detail-item {
    padding: 16px 0;
    border-bottom: 1px solid #F2F3F8;
}

.detail-item:last-child {
    border-bottom: none;
}

.detail-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #646C9A;
    margin-bottom: 8px;
    font-weight: 500;
}

.detail-value {
    font-size: 14px;
    color: #2c3e50;
}

.subject-value {
    font-weight: 500;
}

.policy-value {
    color: #5867DD;
    font-weight: 600;
}

.policy-chart-container {
    margin-top: 12px;
    display: flex;
    justify-content: flex-start;
}

#policy-chart {
    width: 50px !important;
    height: 50px !important;
}

/* ========================================
   DNS CARDS
   ======================================== */

.dns-card {
    margin-bottom: 16px;
}

.dns-card:last-child {
    margin-bottom: 0;
}

.main-records {
    padding: 16px 25px;
}

.dns-record-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 0;
}

.main-records .dns-record-item {
    border-bottom: 1px solid #F2F3F8;
    padding: 12px 0;
}

.main-records .dns-record-item:last-child {
    border-bottom: none;
}

.record-icon {
    flex-shrink: 0;
}

.record-icon.status-valid {
    color: #60D3B1;
}

.record-icon.status-invalid {
    color: #E74C3C;
}

.record-content {
    flex: 1;
}

.record-title {
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.record-status {
    font-size: 13px;
    font-weight: 500;
}

.record-status.status-valid {
    color: #60D3B1;
}

.record-status.status-invalid {
    color: #E74C3C;
}

/* ========================================
   SOURCE TABLE
   ======================================== */

.source-table-card {
    overflow-x: auto;
    margin-bottom: 20px;
}

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

.source-details-table thead {
    background: #F2F3F8;
}

.source-details-table th {
    padding: 16px 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #646C9A;
    border-bottom: 2px solid #EBEDF2;
}

.source-details-table td {
    padding: 16px 12px;
    font-size: 13px;
    color: #2c3e50;
    border-bottom: 1px solid #F2F3F8;
}

.source-ip-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ip-img-flag {
    display: inline-flex;
    height: auto;
}

.country-flag-img {
    width: 20px;
    height: 15px;
}

.source-ip {
    color: #5867DD;
    font-weight: 500;
}

/* ========================================
   HEADERS ACCORDION
   ======================================== */

.headers-card {
    margin-bottom: 0;
}

.headers-accordion {
    border-radius: 4px;
    overflow: hidden;
}

.accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    background: #F2F3F8;
    cursor: pointer;
    transition: background 0.3s ease;
}

.accordion-header:hover {
    background: #EBEDF2;
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.title-text {
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
}

.title-description {
    font-size: 13px;
    color: #646C9A;
}

.btn-toggle {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.btn-toggle.rotated {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    padding: 20px 25px;
}

.accordion-content.show {
    display: block;
}

.headers-mode-switcher {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    border-bottom: 2px solid #F2F3F8;
}

.mode-btn {
    padding: 12px 24px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 600;
    color: #646C9A;
    cursor: pointer;
    position: relative;
    transition: color 0.3s ease;
}

.mode-btn.active {
    color: #5867DD;
}

.mode-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: #5867DD;
}

.mode-btn:hover {
    color: #5867DD;
}

/* Make entire header clickable with hover */
.email-header-accordion-title {
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.email-header-accordion-title:hover {
    background-color: #f8f9fa;
}

/* Button full width */
.email-header-accordion-title .btn {
    width: 100%;
    text-align: left;
    padding: 1rem 2.5rem 1rem 1.25rem;
    /* Extra right padding for arrow */
    border-radius: 0;
    color: inherit;
    text-decoration: none;
    position: relative;
}

/* Arrow icon */
.email-header-accordion-title .btn:after {
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    font-size: 1rem;
    content: "\f078";
    /* fa-chevron-down */
    color: #5d78ff;
    transition: transform 0.3s ease, color 0.3s ease;
}

/* When collapsed (closed) */
.email-header-accordion-title .btn.collapsed:after {
    transform: translateY(-50%) rotate(-90deg);
    color: #74788d;
}

/* Remove default button styles */
.email-header-accordion-title .btn:hover,
.email-header-accordion-title .btn:focus {
    text-decoration: none;
    box-shadow: none;
    outline: none;
}

.email-header-accordion-title h5 {
    margin: 0;
}

/* Human Headers */
.headers-table {
    width: 100%;
    border-collapse: collapse;
}

.headers-table th {
    padding: 12px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
    background: #F2F3F8;
    border: 1px solid #EBEDF2;
    width: 200px;
    vertical-align: top;
}

.headers-table td {
    padding: 12px;
    font-size: 13px;
    color: #646C9A;
    border: 1px solid #F2F3F8;
    word-break: break-all;
}

.card-body #human-header-content {
    padding-left: 0px !important;
    padding-right: 0px !important;
}

/* Raw Headers */
.headers-raw {
    position: relative;
}

.raw-header-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
}

.btn-copy-raw {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #5867DD;
    border: none;
    border-radius: 4px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-copy-raw:hover {
    background: #025dcc;
}

#raw-headers-content {
    border: 1px solid #ebedf2;
    background: #ffffff;
    color: #595d6e;
    padding: 16px 16px 16px 16px;
    border-radius: 4px;
    font-family: 'Muli', monospace;
    font-size: 14px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.card-body #raw-header-content {
    padding: 0px !important;
}

.accordion #collpase-email-header .card-body {
    padding-left: 0px !important;
    padding-right: 0px !important;
}

/* ========================================
   SAME EMAIL NOTIFICATION
   ======================================== */

.same-email-notification {
    background: linear-gradient(135deg, #E8FFF3 0%, #F0F9FF 100%);
    border: 1px solid #60D3B1;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
    animation: slideDown 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(96, 211, 177, 0.15);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.notification-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.notification-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-text {
    flex: 1;
}

.notification-text strong:first-child {
    color: #2c3e50;
    font-size: 15px;
    display: block;
    margin-bottom: 4px;
}

.notification-text p {
    color: #646C9A;
    font-size: 13px;
    margin: 0;
}

.notification-text p strong {
    color: #4875F4;
    font-weight: 600;
}

.notification-close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 24px;
    color: #646C9A;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.notification-close:hover {
    color: #2c3e50;
    transform: scale(1.1);
}

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

@media (max-width: 1200px) {
    .mailauth-results-grid {
        grid-template-columns: 1fr;
    }

    .details-grid {
        grid-template-columns: 1fr;
    }
}

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

    .error-info-container {
        width: 100%;
        justify-content: space-between;
    }

    .email-info-grid {
        grid-template-columns: 1fr;
    }

    .compliance-legend {
        flex-direction: column;
        gap: 12px;
    }

    .source-table-card {
        overflow-x: scroll;
    }

    .source-details-table {
        min-width: 800px;
    }
}