/* Base styles and utilities */
[x-cloak] {
    display: none !important;
}

/* Layout containers */
.dmarc-dashboards .loader {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dmarc-dashboards .categories-view {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
}

/* Category boxes */
.dmarc-dashboards .category-box {
    flex-basis: calc(33.33% - 20px);
    margin: 10px;
    padding: 20px;
    border-radius: 16px;
    background-color: #fff;
    position: relative;
    z-index: 0;
    overflow: visible;
}

.dmarc-dashboards .category-box .category-title {
    font-size: 18px;
}

.dmarc-dashboards .category-box .category-title a {
    display: inline-flex;
    padding: 8px 16px;
    justify-content: center;
    align-items: center;
    gap: 10px;
    background-color: #e5e8eb;
    color: #000;
    border-radius: 16px;
    font-size: 14px;
    transition: box-shadow 0.2s ease-out;
}

.dmarc-dashboards .category-box .category-title a:hover,
.dmarc-dashboards .category-box .category-title a:focus {
    box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
}

/* Stats and chart containers */
.dmarc-dashboards .category-box .category-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
    overflow: visible;
}

.dmarc-dashboards .category-box .category-stats .cat-chart {
    flex-basis: 60%;
    will-change: transform;
    transform: translate3d(0, 0, 0); /* Force a compositing layer */
    padding: 5px; /* Add some padding around the chart container */
    position: relative; /* Ensure content can overflow properly */
    overflow: visible; /* Allow chart elements to overflow */
    z-index: 1;
}

.dmarc-dashboards .category-box .category-stats .cat-chart canvas {
    overflow: visible !important; /* Force chart overflow to be visible */
    width: 100% !important;
    height: auto;
    image-rendering: -webkit-optimize-contrast; /* Improves rendering on Webkit */
    image-rendering: crisp-edges; /* Modern browsers */
    position: relative;
    left: 0;
    top: 0;
    backface-visibility: hidden; /* Prevents blurring during animations */
    -webkit-font-smoothing: subpixel-antialiased;
}

/* Bars styling */
.dmarc-dashboards .category-box .category-stats .cat-bars {
    flex-basis: 40%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar {
    padding-left: 35px;
    position: relative;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar::before {
    content: '';
    display: block;
    position: absolute;
    left: 0;
    top: 50%;
    width: 24px;
    height: 24px;
    transform: translateY(-50%);
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar.spf-b::before {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/mail.svg);
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar.dmarc-b::before {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/shield.svg);
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar.bimi-b::before {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/globe.svg);
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar .c-bar {
    background-color: #f6f8f9;
    border-radius: 5px;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar .c-bar .bar {
    background-color: #09bd69;
    border-radius: 5px;
    height: 10px;
}

.category-box .category-stats .cat-bars .info-bar .c-title {
    display: flex;
    justify-content: space-between;
    font-size: 18px;
    color: #000;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar .c-title span:nth-child(1) {
    font-weight: 500;
}

.dmarc-dashboards .category-box .category-stats .cat-bars .info-bar .c-title span:nth-child(2) {
    font-size: 14px;
}

/* Modal styles */
#dmarc-dashboards-details-modal {
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
}

#dmarc-dashboards-details-modal .modal-content {
    background-color: #fff;
    border-radius: 10px;
    width: 80vw;
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 30px 40px 40px;
    max-height: 80vh;
    transform: translateZ(0);
    will-change: transform;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#dmarc-dashboards-details-modal .modal-content > div {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    max-height: calc(90vh - 60px);
    position: relative;
    -webkit-overflow-scrolling: touch;
}

#dmarc-dashboards-details-modal .modal-content > div h5 {
    font-size: 40px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    position: sticky;
    top: 0;
    background-color: #fff;
    padding: 15px 0 25px; /* Increased bottom padding */
    margin: 0; /* Remove any margin that might create gaps */
    z-index: 10;
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

/* Create pseudo element to fill the gap between h5 and table header */
#dmarc-dashboards-details-modal .modal-content > div h5::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 10px; /* Overlap with thead */
    background-color: #fff;
    z-index: 5;
}

/* Add shadow to bottom of heading for visual separation */
#dmarc-dashboards-details-modal .modal-content > div h5::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 5px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), transparent);
    pointer-events: none;
}

/* Close button */
#dmarc-dashboards-details-modal .modal-content .close {
    position: absolute;
    top: -35px;
    right: -36px;
    font-size: 29px;
    color: #000;
    cursor: pointer;
    background: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
}

#dmarc-dashboards-details-modal .modal-content .close img {
    width: 24px;
    height: 24px;
}

/* Table styles */
#dmarc-dashboards-details-modal .modal-content .table-wrapper {
    position: relative;
    overflow: visible;
    margin-top: -5px; /* Negative margin to pull it up slightly */
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table {
    width: 100%;
    border-collapse: collapse;
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table thead {
    position: sticky;
    top: 85px; /* Adjust this value based on the height of your h5 heading */
    background-color: #fff;
    z-index: 5;
    /* Fix the 1px jump */
    transform: translateZ(0);
    will-change: transform;
    backface-visibility: hidden;
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table thead th {
    border-bottom: 1px solid #e5e7eb;
    padding: 15px 10px;
    text-align: left;
    font-weight: 500;
    font-size: 18px;
    background-color: #fff;
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table thead::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -5px;
    height: 5px;
    background: linear-gradient(to bottom, rgba(0,0,0,0.1), transparent);
    pointer-events: none;
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td {
    padding: 10px;
    font-size: 16px;
    border-bottom: 1px solid #e5e7eb;
    line-height: 1;
}

#dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody tr:hover,
#dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody tr:focus {
    background-color: #f6f8f9;
}

/* Tooltip styles */
.chartjs-tooltip {
    max-width: 120px;
    white-space: normal;
    word-wrap: break-word;
    text-align: center;
    line-height: 1.2;
    font-size: 11px;
    z-index: 9999 !important;
    pointer-events: none;
    opacity: 1 !important;
    position: absolute;
    overflow: visible !important;
    padding: 6px 8px;
}

.dmd-tooltip {
    position: relative;
    display: inline-block;
    cursor: pointer;
}

.dmd-tooltip .t-icon {
    display: inline-block;
    width: 28px;
    height: 28px;
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}

/* Status icons */
.dmd-tooltip .t-icon.good {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/icon-ok.svg);
}

.dmd-tooltip .t-icon.warning {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/icon-warning.svg);
}

.dmd-tooltip .t-icon.error {
    background-image: url(/modules/mod_dmarc_dashboards/assets/images/icon-error.svg);
}

/* Tooltip type styles */
.tooltip-type-error .tippy-box {
    background-color: #ef4444;
    color: #fff;
}

.tooltip-type-good .tippy-box {
    background-color: #2ba729;
    color: #fff;
}

.tooltip-type-warning .tippy-box {
    background-color: #f97316;
    color: #fff;
}

/* Tooltip arrow styles */
.tooltip-type-error .tippy-box[data-placement^='right'] > .tippy-arrow::before {
    border-right-color: #ef4444;
}

.tooltip-type-error .tippy-box[data-placement^='left'] > .tippy-arrow::before {
    border-left-color: #ef4444;
}

.tooltip-type-warning .tippy-box[data-placement^='right'] > .tippy-arrow::before {
    border-right-color: #f97316;
}

.tooltip-type-warning .tippy-box[data-placement^='left'] > .tippy-arrow::before {
    border-left-color: #f97316;
}

.tooltip-type-good .tippy-box[data-placement^='right'] > .tippy-arrow::before {
    border-right-color: #2ba729;
}

.tooltip-type-good .tippy-box[data-placement^='left'] > .tippy-arrow::before {
    border-left-color: #2ba729;
}

/* Chart tooltip styling */
.tippy-box[data-theme~='chart-tooltip'] {
    background-color: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 8px 12px;
    font-size: 14px;
    line-height: 1.4;
    border-radius: 4px;
    max-width: 200px;
    text-align: left; /* Changed from center to left for better alignment with dot */
    z-index: 9999;
    pointer-events: none; /* Prevent tooltip from interfering with hover */
}

.tippy-box[data-theme~='chart-tooltip'] .tippy-arrow {
    color: rgba(0, 0, 0, 0.9);
}

/* Ensure tooltips are always on top */
.tippy-box[data-theme~='chart-tooltip'][data-placement^='top'] > .tippy-arrow::before {
    border-top-color: rgba(0, 0, 0, 0.9);
}

.tippy-box[data-theme~='chart-tooltip'][data-placement^='bottom'] > .tippy-arrow::before {
    border-bottom-color: rgba(0, 0, 0, 0.9);
}

.tippy-box[data-theme~='chart-tooltip'][data-placement^='left'] > .tippy-arrow::before {
    border-left-color: rgba(0, 0, 0, 0.9);
}

.tippy-box[data-theme~='chart-tooltip'][data-placement^='right'] > .tippy-arrow::before {
    border-right-color: rgba(0, 0, 0, 0.9);
}

.chart-tooltip-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-tooltip-content .color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Skeleton loading animation */
@keyframes shimmer {
    0% { background-position: -468px 0; }
    100% { background-position: 468px 0; }
}

/* Skeleton base style */
.dmarc-dashboards .skeleton {
    background: #f6f7f8 linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%) no-repeat;
    background-size: 800px 104px;
    animation: shimmer 1.5s infinite linear;
}

/* Skeleton layout elements */
.dmarc-dashboards .skeleton-categories {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
}

.dmarc-dashboards .skeleton-box {
    flex-basis: calc(33.33% - 20px);
    margin: 10px;
    padding: 20px;
    border-radius: 16px;
    background-color: #fff;
    position: relative;
    z-index: 0;
    overflow: visible;
}

.dmarc-dashboards .skeleton-title {
    height: 20px;
    width: 60%;
    border-radius: 16px;
}

.dmarc-dashboards .skeleton-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 30px;
    gap: 10px;
    overflow: visible;
}

.dmarc-dashboards .skeleton-chart {
    width: 180px; /* Fixed width */
    height: 180px; /* Fixed height */
    max-width: 100%; /* Ensure it doesn't overflow container */
    border-radius: 50%;
    margin: 0 auto; /* Center the circle */
    aspect-ratio: 1/1; /* Force 1:1 aspect ratio */
}

.dmarc-dashboards .skeleton-bars {
    flex-basis: 40%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.dmarc-dashboards .skeleton-bar {
    height: 30px;
    width: 100%;
    border-radius: 5px;
}

/* Responsive styles */
@media screen and (min-width: 576px) and (max-width: 1199.95px) {
    .dmarc-dashboards .category-box,
    .dmarc-dashboards .skeleton-box {
        flex-basis: calc(50% - 20px);
    }
}

@media screen and (max-width: 920px) {
    /* Layout adjustments */
    .dmarc-dashboards .categories-view,
    .dmarc-dashboards .skeleton-categories {
        flex-direction: column;
    }

    .dmarc-dashboards .category-box,
    .dmarc-dashboards .skeleton-box {
        flex-basis: 100%;
    }

    /* Content layout */
    .dmarc-dashboards .category-stats,
    .dmarc-dashboards .skeleton-stats {
        flex-direction: column;
        align-items: center;
    }

    /* Chart sizing adjustments */
    .dmarc-dashboards .skeleton-chart {
        margin: 0 auto 20px;
        width: 150px !important;
        height: 150px !important;
    }

    /* Make bars full width */
    .dmarc-dashboards .category-box .category-stats .cat-bars,
    .dmarc-dashboards .skeleton-bars {
        width: 100%;
        flex-basis: 100%;
    }
}

@media (max-width: 768px) {
    /* Modal adjustments */
    #dmarc-dashboards-details-modal {
        width: 100vw; /* Force full width */
        height: 100vh; /* Force full height */
        position: fixed;
        left: 0;
        top: 0;
        overflow: hidden; /* Prevent page shift */
    }

    #dmarc-dashboards-details-modal .modal-content {
        padding: 20px 15px 30px;
        width: 92vw;
        transform: translate3d(0, 0, 0); /* Force GPU acceleration */
        -webkit-transform: translate3d(0, 0, 0);
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
        position: relative;
        overflow: hidden; /* Prevent content from causing shifts */
    }

    #dmarc-dashboards-details-modal .modal-content .close {
        top: -2px;
        right: 0;
    }

    #dmarc-dashboards-details-modal .modal-content > div {
        width: 100%;
        padding-top: 5px;
    }

    #dmarc-dashboards-details-modal .modal-content > div h5 {
        font-size: 26px; /* Smaller heading on mobile */
        padding: 10px 0; /* Adjust padding for smaller screens */
    }

    #dmarc-dashboards-details-modal .modal-content > div h5::before,
    #dmarc-dashboards-details-modal .modal-content > div h5::after {
        bottom: 0; /* Adjust the position to prevent overlap */
    }

    /* Table wrapper adjustments */
    #dmarc-dashboards-details-modal .table-wrapper {
        padding-top: 10px;
        margin: 0;
        width: 100%;
        padding-top: 20px !important; /* Force more padding at the top */
        margin-top: 10px !important; /* Add positive margin to create space */
    }

    /* Table styles for mobile */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table {
        display: block;
        width: 100%;
        min-width: 0;
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    #dmarc-dashboards-details-modal .modal-content .table-wrapper table thead {
        display: none;
    }

    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody {
        width: 100%;
        display: block;
        box-sizing: border-box;
    }

    /* Transform rows into cards */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody tr {
        display: block;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05);
        padding: 0;
        width: 100%;
        margin: 0 0 15px 0;
        box-sizing: border-box;
    }

    /* Cell styling for mobile */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td {
        display: flex;
        padding: 10px 15px;
        border-bottom: none;
        align-items: center;
        justify-content: space-between;
        font-size: 14px;
        position: relative;
        width: 100%;
        box-sizing: border-box;
    }

    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:not(:last-child) {
        border-bottom: 1px solid #f0f0f0;
    }

    /* Add labels for mobile view */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        flex: 1;
        text-align: left;
        padding-right: 10px;
        color: #4a5568;
        text-transform: capitalize;
        display: block;
    }

    /* Domain name row styling */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:first-child {
        display: flex;
        justify-content: flex-start !important;
        text-align: left !important;
        padding: 12px 15px 15px 6px;
        background-color: #f8fafc;
        border-radius: 8px 8px 0 0;
        font-weight: 600;
    }

    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:first-child span {
        text-align: left !important;
        margin-right: auto !important;
        margin-left: 0 !important;
        flex-grow: 1;
        width: 100%;
        display: block;
    }

    /* Status column styling */
    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:not(:first-child) {
        justify-content: flex-start;
    }

    #dmarc-dashboards-details-modal .modal-content .table-wrapper table tbody td:not(:first-child) .dmd-tooltip {
        margin-left: auto;
    }

    /* Skeleton responsive styles */
    .dmarc-dashboards .skeleton-chart {
        width: 150px; /* Slightly smaller on mobile */
        height: 150px;
        margin: 0 auto;
    }

    .dmarc-dashboards .skeleton-bars {
        width: 100%;
    }
}

/* Country selector styles */
.dmarc-dashboards .dmarc-dashboards-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding: 0 10px;
}
.dmarc-dashboards  .custom-select {
    position: relative;
    width: 200px;
}

.dmarc-dashboards .select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 11px;
    border: 1px solid #E5E8EB;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
    font-size: 16px;
}

.dmarc-dashboards .select-trigger:hover {
    border-color: #999;
}

.dmarc-dashboards .select-trigger.open {
    border-color: #007cba;
    border-radius: 8px;
}

.dmarc-dashboards .selected-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dmarc-dashboards .flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}

.dmarc-dashboards .chevron {
    transition: transform 0.2s;
}

.dmarc-dashboards .chevron.rotate {
    transform: rotate(180deg);
}

.dmarc-dashboards .select-options {
    position: absolute;
    top: calc(100% + 19px);
    left: 0;
    right: 0;
    background: white;
    border-top: none;
    border-radius: 16px;
    max-height: 200px;
    overflow: hidden;
    z-index: 1000;
    box-shadow: 0px 5px 11px 0px rgba(0, 0, 0, 0.20);
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    padding: 8px;
}

.dmarc-dashboards .select-options-inner {
    max-height: 200px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
    padding-right: 2px;
    margin-right: -2px;
}

.dmarc-dashboards .select-options-inner::-webkit-scrollbar {
    width: 6px;
}
.dmarc-dashboards .select-options-inner::-webkit-scrollbar-track {
    background: transparent;
}

.dmarc-dashboards .select-options-inner::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
    border: 1px solid transparent;
    background-clip: content-box;
}

.dmarc-dashboards .select-options-inner::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

/* Webkit scrollbar styling for Chrome/Safari */
.dmarc-dashboards .select-options::-webkit-scrollbar {
    width: 6px;
}

.dmarc-dashboards .select-options::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 0 8px 8px 0; /* Match the container border radius */
}

.dmarc-dashboards .select-options::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
    border: 1px solid transparent;
    background-clip: content-box;
}

.dmarc-dashboards .select-options::-webkit-scrollbar-thumb:hover {
    background-color: #999;
}

.dmarc-dashboards .option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background-color 0.2s;
    margin-bottom: 0;
}

.dmarc-dashboards .option:hover {
    background-color: #f5f5f5;
}

.dmarc-dashboards .option:last-child {
    margin-bottom: 4px;
}

.dmarc-dashboards .option.selected {
    background-color: #e3f2fd;
}
.dmarc-dashboards .option .flag-icon {
    width: 20px;
    height: 15px;
    object-fit: cover;
    border-radius: 2px;
}
