/*
 * Referrer Insights Dashboard - WP_List_Table Light Theme Styles
 * This CSS file targets standard WordPress admin table elements
 * to achieve a clean, modern, light-themed look.
 */

/* ====================================
   1. GLOBAL & CONTAINER STYLES
   ==================================== */

/* Target the main screen wrapper for the page background */
body,
#wpbody-content {
    background-color: #f9fafb !important;
    /* bg-gray-50 */
    color: #111827;
    /* text-gray-900 */
}

/* ====================================
   2. WP_LIST_TABLE STYLES
   ==================================== */

/* Main table element */
.wp-list-table {
    /* border-collapse: collapse; */
    /* font-size: 0.875rem; */
    /* padding: 0; */
    border-radius: 0.5rem;
    overflow: hidden;
    border-color: #d1d5db !important;
    margin: 20px 0;
}

/* Table Header (Thead/Tbody header) */
.wp-list-table thead,
.wp-list-table tfoot {
    background-color: #f3f4f6;
    /* bg-gray-100 */
    color: #374151;
    /* text-gray-700 */
    text-transform: uppercase;
    font-size: 0.75rem;
    /* text-xs */
}

/* Column Headers */
.wp-list-table .manage-column {
    padding: 1rem 1.5rem;
    /* px-6 py-4 */
    border-bottom: 1px solid #e5e7eb;
    /* border-gray-200 */
    cursor: pointer;
    vertical-align: middle;
    line-height: normal;
    font-weight: 600;
}

/* Column headers with links (for sorting) */
.wp-list-table .manage-column a {
    color: #374151;
    /* text-gray-700 */
    text-decoration: none;
    outline: none !important;
    box-shadow: none !important;
}

.wp-list-table .manage-column a:hover {
    color: #2563eb;
    /* text-blue-600 */
}

/* Table Rows */
.wp-list-table tr {
    border-bottom: 1px solid #e5e7eb;
    /* border-gray-200 */
    transition: background-color 150ms ease;
}

.wp-list-table tr:hover {
    background-color: #f9fafb;
    /* hover:bg-gray-50 */
}

/* Alternate Rows (if WP uses .alternate) */
.wp-list-table .alternate {
    background-color: #ffffff;
    /* base bg-white */
}

.wp-list-table .alternate:hover {
    background-color: #f9fafb;
    /* hover:bg-gray-50 */
}

/* Table Cells */
.wp-list-table td,
.wp-list-table th.check-column {
    border-bottom: none;
    vertical-align: middle;
    line-height: 1.5;
}
.wp-list-table th.sorted * {
    color: #1956ff !important;
    font-weight: 700;
}
/* Special styling for the Title column */
.wp-list-table .column-title {
    color: #111827;
    /* text-gray-900 */
    font-weight: 500;
}

.wp-list-table .no-items {
    text-align: center;
    padding: 3rem 0;
    color: #6b7280;
    font-weight: 500;
}

/* ====================================
   3. TAB NAVIGATION STYLES
   ==================================== */

.nav-tab-wrapper {
    margin: 0 !important;
    padding: 0 1.5rem !important;
    /* Matches the table content padding */
    background-color: #ffffff;
    /* bg-white */
    border-bottom: 1px solid #e5e7eb !important;
    /* border-gray-200 */
    line-height: normal;
}

.nav-tab {
    padding: 0.75rem 1.5rem;
    /* py-3 px-6 from HTML */
    color: #6b7280 !important;
    /* text-gray-500 */
    border: none !important;
    /* Remove default WP borders */
    background-color: transparent !important;
    transition: color 150ms ease;
    transition: all .3s ease;
}

.nav-tab:not(.nav-tab-active):hover {
    box-shadow: 0px -3px 0px 0px rgb(37 99 235 / 50%) inset;
}

.nav-tab-active {
    color: #2563eb !important;
    /* text-blue-600 */
    font-weight: 600;
    /* Blue underline effect */
    box-shadow: 0px -3px 0px 0px #2563eb inset;
    border-bottom: none !important;
    /* Ensure the shadow is the only bottom line */
}

/* ====================================
   4. BULK ACTION & PAGINATION (TABLENAV)
   ==================================== */

/* Top and bottom sections containing bulk actions and pagination */
.tablenav {
    background-color: #ffffff;
    /* bg-white */
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    /* Use border-top here for bottom tablenav */
}

/* Form Elements (Select, Search) */
.refsight-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0 10px;
    margin: 10px 0;
    align-items: center;
}

.refsight-export-form {
    float: right;
    margin: 11px 0;
}

select,
input[type="search"],
input[type="text"],
input[type="date"] {
    background-color: #ffffff !important;
    border: 1px solid #d1d5db !important;
    border-radius: 0.5rem !important;
    transition: border-color 150ms ease !important;
}

/* Base checkbox reset */
input[type="checkbox"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;

    width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.4rem;
    border: 1.5px solid #c7d2fe;
    background-color: #ffffff;
    cursor: pointer;
    position: relative;

    transition:
        background-color 160ms ease,
        border-color 160ms ease,
        box-shadow 160ms ease,
        transform 120ms ease;
}

/* Hover */
input[type="checkbox"]:hover:not(:disabled) {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Active click */
input[type="checkbox"]:active:not(:disabled) {
    transform: scale(0.95);
}

/* Checked state */
input[type="checkbox"]:checked {
    background-color: #2563eb;
    border-color: #2563eb;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.35);
}

/* Checkmark */
input[type="checkbox"]::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0.28rem;
    height: 0.6rem;
    border: solid #ffffff;
    border-width: 0 2.5px 2.5px 0;
    transform: translate(-50%, -60%) rotate(45deg) scale(0.8);
    opacity: 0;
    transition: opacity 140ms ease, transform 140ms ease;
}

/* Show checkmark */
input[type="checkbox"]:checked::after {
    opacity: 1;
    transform: translate(-50%, -60%) rotate(45deg) scale(1);
}

/* Focus (keyboard accessibility) */
input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(147, 197, 253, 0.9);
}

/* Disabled */
input[type="checkbox"]:disabled {
    background-color: #f1f5f9;
    border-color: #cbd5f5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Indeterminate (optional – great for tables) */
input[type="checkbox"]:indeterminate {
    background-color: #2563eb;
    border-color: #2563eb;
}

input[type="checkbox"]:indeterminate::after {
    width: 0.55rem;
    height: 0.125rem;
    border: none;
    background-color: #ffffff;
    transform: translate(-50%, -50%);
    opacity: 1;
}

/* Table column spacing */
th.check-column,
td.check-column {
    padding: 12px 6px !important;
    border-right: 1px solid #e5e7eb;
}

/* Action Buttons (Bulk, Filter, etc.) - Primary Blue Accent */
.button,
.button-primary {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border: none;
    border-radius: 0.5rem !important;
    height: auto;
    line-height: normal;
    text-transform: capitalize;
    font-weight: 600;
    transition: background-color 150ms ease;
}

.button:hover,
.button-primary:hover {
    background-color: #1d4ed8;
}

/* Secondary Buttons (e.g., Reset/Go button if not bulk action) */
.button-secondary {
    background-color: #f3f4f6 !important;
    color: #374151 !important;
    border: 1px solid #d1d5db !important;
    box-shadow: none;
}

.button-secondary:hover {
    background-color: #e5e7eb !important;
    /* hover:bg-gray-200 */
    color: #111827 !important;
}

.alignleft.actions.bulkactions {
    display: flex;
}

.tablenav br {
    display: none;
}

.tablenav.bottom {
    border-top: none;
    border-bottom: 1px solid #e5e7eb;
}

.loading-overlay {
    position: relative;
}

.loading-overlay::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.7);
    z-index: 10;
}

.loading-overlay::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    margin-left: -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1d4ed8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 11;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.refsight-forms {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.refsight-analytics-charts {
    margin-top: 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2rem;
}

.refsight-analytics-charts h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.5em;
    color: #333;
}

.refsight-analytics-charts canvas {
    max-width: 100%;
    height: 400px;
}

.refsight-analytics-charts>div {
    background-color: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 1.5rem;
    transition: all 0.3s ease;
}

/* Hover effect for interactivity */
.refsight-analytics-charts>div:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid #6366f1;
}

/* Two columns on desktop */
.refsight-analytics-charts>div:nth-child(1) {
    flex: 1 1 100%;
    min-height: 600px;
}

.refsight-analytics-charts>div:nth-child(2) {
    flex: 1 1 300px;
    min-height: 500px;
}

.refsight-analytics-charts>div:nth-child(3) {
    flex: 2 1 600px;
    min-height: 400px;
}

@media (max-width: 768px) {
    .refsight-analytics-charts {
        padding: 10px;
    }

    .refsight-analytics-charts>div {
        flex: 1 1 100% !important;
        /* All cards take full width */
    }

    .refsight-analytics-charts>div:nth-child(1) {
        min-height: 400px;
    }

    .refsight-analytics-charts>div:nth-child(2) {
        min-height: 400px;
    }

    .refsight-analytics-charts>div:nth-child(3) {
        min-height: 400px;
    }
}