/* Custom styles for Resulam Royalties Dashboard */

/* Dropdown styling for author selector */
.Select-menu-outer {
    display: block !important;
}

.Select--multi .Select-value {
    display: inline-block;
    margin-right: 5px;
    margin-bottom: 5px;
}

/* Vertical dropdown menu */
.Select-menu {
    max-height: 500px !important;
}

.Select-option {
    padding: 10px 15px !important;
    white-space: normal !important;
    word-wrap: break-word !important;
}

.Select-option:before {
    content: '☐ ' !important;
    margin-right: 8px;
    font-weight: bold;
}

.Select-option.is-selected:before {
    content: '☑ ' !important;
    color: #2c3e50;
}

/* Dropdown focused state */
.Select-option.is-focused {
    background-color: #f5f5f5 !important;
}

.Select-option.is-selected {
    background-color: #e8f4f8 !important;
    color: #2c3e50 !important;
}

/* Checklist styling if using checklist component */
.author-checklist {
    columns: 2;
    column-gap: 20px;
}

.author-checklist label {
    display: block;
    margin-bottom: 8px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.author-checklist label:hover {
    background-color: #f0f0f0;
}

/* Bar chart styling */
.plotly-graph-div {
    font-family: Arial, sans-serif;
}

/* Subtle motion + interactions (dashboard "liveliness") */
.card {
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .card:hover {
        transform: translateY(-2px);
        box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35) !important;
        border-color: rgba(255, 255, 255, 0.12);
    }
}

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

/* Animate cards when tab content is (re)rendered */
#tab-content .card,
#sales-overview-section .card {
    animation: fadeUp 320ms ease both;
}

@keyframes metricPop {
    0% {
        transform: scale(0.96);
        filter: brightness(0.9);
        text-shadow: none;
    }
    35% {
        transform: scale(1.05);
        filter: brightness(1.15);
        text-shadow: 0 0 18px rgba(255, 255, 255, 0.25);
    }
    100% {
        transform: scale(1);
        filter: none;
        text-shadow: none;
    }
}

.metric-pop {
    display: inline-block;
    will-change: transform, filter;
    animation: metricPop 520ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

@keyframes cardPop {
    0% {
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    }
    40% {
        box-shadow: 0 16px 40px rgba(13, 110, 253, 0.25);
    }
    100% {
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
    }
}

.card-pop {
    animation: cardPop 520ms ease;
}

/* Header link buttons micro-interactions */
.header-social-links .btn {
    transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

@media (hover: hover) and (pointer: fine) {
    .header-social-links .btn:hover {
        transform: translateY(-1px);
        filter: brightness(1.05);
        box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
    }
}

/* Respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    #tab-content .card,
    #sales-overview-section .card,
    .metric-pop,
    .card-pop {
        animation: none !important;
    }
    .card,
    .header-social-links .btn {
        transition: none !important;
    }
}

/* Legend styling */
.plotly .legend {
    max-height: 500px;
    overflow-y: auto;
}

/* Button group spacing */
.btn-group {
    display: flex;
    gap: 10px;
}

/* Author earnings list styling */
.author-list-item {
    color: rgba(255, 255, 255, 0.92) !important;
}

body.light-mode .author-list-item {
    color: #212529 !important;
}

.author-list-total {
    color: #00DDFF !important;
}

body.light-mode .author-list-total {
    color: #00DDFF !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .author-checklist {
        columns: 1;
    }
}

/* Dashboard tabs: render as button grid on small screens */
@media (max-width: 768px) {
    #dashboard-tabs.nav-tabs,
    #dashboard-tabs .nav-tabs {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        border-bottom: 0 !important;
    }

    #dashboard-tabs.nav-tabs .nav-item,
    #dashboard-tabs .nav-tabs .nav-item {
        margin: 0 !important;
    }

    #dashboard-tabs.nav-tabs .nav-link,
    #dashboard-tabs .nav-tabs .nav-link {
        width: 100%;
        text-align: center;
        position: relative;
        overflow: hidden;
        border: 1px solid rgba(255, 255, 255, 0.22) !important;
        border-radius: 0.85rem !important;
        padding: 0.65rem 0.85rem !important;
        background: linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.10),
            rgba(255, 255, 255, 0.04)
        );
        box-shadow:
            0 10px 24px rgba(0, 0, 0, 0.32),
            inset 0 1px 0 rgba(255, 255, 255, 0.10);
        font-weight: 700;
        white-space: normal;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.35rem;
        transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
    }

    #dashboard-tabs.nav-tabs .nav-link.active,
    #dashboard-tabs .nav-tabs .nav-link.active {
        background: linear-gradient(135deg, #0d6efd, #6610f2) !important;
        border-color: rgba(13, 110, 253, 0.9) !important;
        color: #fff !important;
        box-shadow:
            0 14px 30px rgba(13, 110, 253, 0.35),
            0 10px 24px rgba(0, 0, 0, 0.25),
            inset 0 1px 0 rgba(255, 255, 255, 0.18);
    }

    #dashboard-tabs.nav-tabs .nav-link:hover,
    #dashboard-tabs .nav-tabs .nav-link:hover {
        transform: translateY(-1px);
        box-shadow:
            0 16px 34px rgba(0, 0, 0, 0.35),
            inset 0 1px 0 rgba(255, 255, 255, 0.12);
        border-color: rgba(255, 255, 255, 0.28) !important;
    }

    #dashboard-tabs.nav-tabs .nav-link:active,
    #dashboard-tabs .nav-tabs .nav-link:active {
        transform: translateY(0);
        box-shadow:
            0 10px 20px rgba(0, 0, 0, 0.28),
            inset 0 2px 10px rgba(0, 0, 0, 0.25);
    }

    #dashboard-tabs.nav-tabs .nav-link:focus-visible,
    #dashboard-tabs .nav-tabs .nav-link:focus-visible {
        outline: 3px solid rgba(255, 193, 7, 0.45);
        outline-offset: 2px;
    }

    body.light-mode #dashboard-tabs.nav-tabs .nav-link,
    body.light-mode #dashboard-tabs .nav-tabs .nav-link {
        background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(0, 0, 0, 0.02));
        border-color: rgba(0, 0, 0, 0.12) !important;
        color: #212529 !important;
        box-shadow:
            0 10px 22px rgba(0, 0, 0, 0.12),
            inset 0 1px 0 rgba(255, 255, 255, 0.9);
    }

    body.light-mode #dashboard-tabs.nav-tabs .nav-link.active,
    body.light-mode #dashboard-tabs .nav-tabs .nav-link.active {
        color: #fff !important;
    }
}

@media (max-width: 576px) {
    #dashboard-tabs.nav-tabs,
    #dashboard-tabs .nav-tabs {
        grid-template-columns: 1fr;
    }
}

/* Dropdown text overflow handling - prevent text overlap */
.Select-value-label,
.Select-placeholder,
.Select-input > input,
.Select-control .Select-value .Select-value-label {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
}

/* Dropdown menu options - truncate long text with ellipsis */
.VirtualizedSelectOption,
.Select-option {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    padding: 8px 12px !important;
}

/* Dash Core Components dropdown specific styling */
.dash-dropdown .Select-control {
    overflow: hidden !important;
}

.dash-dropdown .Select-value {
    max-width: calc(100% - 40px) !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.dash-dropdown .Select-menu-outer {
    z-index: 9999 !important;
}

/* Make dropdown menu wider than the control for better readability */
.dash-dropdown .Select-menu-outer {
    min-width: 200px !important;
    width: auto !important;
}

/* Ensure dropdown options show full text on hover via tooltip-like behavior */
.Select-option:hover {
    overflow: visible !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    position: relative;
    z-index: 10000;
}
