/* ==========================================================================
   Ballerina Analytics - Brand Styles
   Fonts: Quicksand (headings) + Karla (body) — from ballerina.cl
   Colors: #A1249A (brand magenta primary), #0C369C (navy secondary)
   Adapted from WordPress palette: --purple, --blue, --blue-1, --green
   ========================================================================== */

:root {
    /* Brand Colors - from ballerina.cl WordPress */
    --ballerina-primary: #A1249A;
    --ballerina-primary-dark: #8e1f87;
    --ballerina-secondary: #0C369C;
    --ballerina-light: #fdf2fa;
    --ballerina-glow: rgba(161, 36, 154, 0.12);
    --ballerina-glow-strong: rgba(161, 36, 154, 0.25);
    --ballerina-green: #6B9A46;
    --ballerina-navy: #001546;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --navbar-height: 64px;

    /* Surfaces */
    --bg-body: #faf8f9;
    --bg-card: #ffffff;
    --border-subtle: rgba(161, 36, 154, 0.08);

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 4px 20px rgba(161, 36, 154, 0.12);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   Base / Reset
   ========================================================================== */

[x-cloak] {
    display: none !important;
}

* {
    scrollbar-width: thin;
    scrollbar-color: #d4a8e0 transparent;
}

*::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: #d4a8e0;
    border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: #A1249A;
}

html {
    scroll-behavior: smooth;
}

/* ==========================================================================
   Typography - Ballerina Brand
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
    font-family: 'Quicksand', sans-serif;
}

/* ==========================================================================
   Page Transitions & Content Loading
   ========================================================================== */

main {
    animation: pageEnter 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* ==========================================================================
   Sidebar - Ballerina Gradient with Glass Effect
   ========================================================================== */

.sidebar-bg {
    background: linear-gradient(180deg,
        #0C369C 0%,
        #0a2e85 25%,
        #08246b 50%,
        #041a52 75%,
        #001546 100%
    );
}

/* Logo glow effect */
.logo-glow {
    box-shadow: 0 0 12px rgba(161, 36, 154, 0.3), 0 0 24px rgba(161, 36, 154, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.25);
}

/* Botanical pattern overlay + enhanced glass effect */
.sidebar-bg::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 80%, rgba(255, 255, 255, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(255, 255, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(161, 36, 154, 0.08) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
    backdrop-filter: blur(1px);
}

/* Glass shimmer layer */
.sidebar-bg::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.03) 0%,
        rgba(255, 255, 255, 0.08) 25%,
        rgba(255, 255, 255, 0.03) 50%,
        rgba(255, 255, 255, 0.0) 100%
    );
    pointer-events: none;
    z-index: 0;
}

.sidebar-bg > * {
    position: relative;
    z-index: 1;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 4px;
}

.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-scroll::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.sidebar-scroll::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* Active sidebar item - glowing animated bar */
.sidebar-nav-item {
    position: relative;
    transition: all var(--transition-base);
}

.sidebar-nav-item[class*="bg-white/20"]::before {
    content: '';
    position: absolute;
    left: 0;
    top: 4px;
    bottom: 4px;
    width: 3px;
    background: linear-gradient(180deg, #d95cba, #ffffff, #d95cba);
    background-size: 100% 200%;
    border-radius: 0 3px 3px 0;
    animation: activeBarGlow 3s ease-in-out infinite;
    box-shadow: 0 0 8px rgba(161, 36, 154, 0.6), 0 0 16px rgba(161, 36, 154, 0.3);
}

@keyframes activeBarGlow {
    0%, 100% { background-position: 0% 0%; opacity: 1; }
    50% { background-position: 0% 100%; opacity: 0.8; }
}

/* Sidebar icon hover animation */
.sidebar-nav-item svg {
    transition: transform var(--transition-base), color var(--transition-base);
}

.sidebar-nav-item:hover svg {
    transform: scale(1.15);
}

.sidebar-nav-item:active svg {
    transform: scale(0.95);
}

/* ==========================================================================
   Navbar - Sticky Header with Scroll Shadow
   ========================================================================== */

header {
    transition: box-shadow var(--transition-base);
    z-index: 10;
}

header.scrolled {
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06), 0 1px 4px rgba(0, 0, 0, 0.04);
}

/* ==========================================================================
   KPI Cards
   ========================================================================== */

.kpi-card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    transition: all var(--transition-base);
    will-change: transform, box-shadow;
}

/* Always-on subtle gradient top border */
.kpi-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--ballerina-primary), var(--ballerina-secondary));
    opacity: 0.4;
    transition: opacity var(--transition-base);
}

.kpi-card:hover::after {
    opacity: 1;
}

.kpi-card:hover {
    border-color: rgba(161, 36, 154, 0.15);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}

/* Staggered animation for KPI cards */
.kpi-stagger > *:nth-child(1) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.05s both; }
.kpi-stagger > *:nth-child(2) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.12s both; }
.kpi-stagger > *:nth-child(3) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.19s both; }
.kpi-stagger > *:nth-child(4) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.26s both; }
.kpi-stagger > *:nth-child(5) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.33s both; }
.kpi-stagger > *:nth-child(6) { animation: kpiEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.40s both; }

@keyframes kpiEntrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   Chart Loading Skeleton
   ========================================================================== */

.chart-skeleton {
    position: relative;
    overflow: hidden;
    transition: opacity var(--transition-slow);
}

.chart-skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(161, 36, 154, 0.06), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Enhanced shimmer for chart loading */
@keyframes shimmerWave {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.chart-skeleton-shimmer {
    background: linear-gradient(
        90deg,
        #fdf2fa 25%,
        #fae6f4 37%,
        #fdf2fa 63%
    );
    background-size: 200% 100%;
    animation: shimmerWave 1.8s ease-in-out infinite;
    border-radius: 0.5rem;
}

/* ==========================================================================
   Cards & Containers
   ========================================================================== */

.bg-white {
    background-color: var(--bg-card);
}

.bg-white h3 {
    font-family: 'Quicksand', sans-serif;
}

/* Chart cards hover lift */
.bg-white.rounded-xl {
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.bg-white.rounded-xl:hover {
    box-shadow: var(--shadow-md);
}

/* Section headers with gradient accent */
.section-header {
    position: relative;
    padding-left: 14px;
}

.section-header::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 2px;
    background: linear-gradient(180deg, var(--ballerina-primary), var(--ballerina-secondary));
}

/* ==========================================================================
   Product Thumbnails
   ========================================================================== */

.product-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fae6f4;
    background-color: #fdf2fa;
    flex-shrink: 0;
    transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.product-thumb:hover {
    transform: scale(1.1);
    border-color: var(--ballerina-primary);
}

.product-thumb-lg {
    width: 40px;
    height: 40px;
}

.product-thumb-placeholder {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fae6f4, #f3e8ff);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--ballerina-primary);
    transition: transform var(--transition-fast);
}

.product-thumb-placeholder:hover {
    transform: scale(1.1);
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table thead th {
    font-family: 'Quicksand', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #741a6e;
    padding: 0.75rem 1rem;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast), background-color var(--transition-fast);
    position: relative;
}

table thead th:hover {
    color: var(--ballerina-primary);
    background-color: rgba(161, 36, 154, 0.04);
}

table thead th .sort-icon {
    display: inline-block;
    margin-left: 4px;
    opacity: 0.3;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

table thead th:hover .sort-icon,
table thead th.sorted .sort-icon {
    opacity: 1;
}

table thead th.sorted .sort-icon {
    color: var(--ballerina-primary);
}

table tbody td {
    padding: 0.75rem 1rem;
    color: #334155;
    white-space: nowrap;
    font-family: 'Karla', sans-serif;
}

table tbody tr {
    transition: background-color var(--transition-fast);
}

/* Alternating row colors - subtle brand tint */
table tbody tr:nth-child(even) {
    background-color: rgba(254, 241, 247, 0.3);
}

table tbody tr:hover {
    background-color: #fdf2fa;
}

/* ==========================================================================
   Pagination - Enhanced
   ========================================================================== */

[id$="-pagination"] {
    background: linear-gradient(180deg, transparent, rgba(254, 241, 247, 0.3));
}

[id$="-pagination"] button {
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    font-family: 'Karla', sans-serif;
}

[id$="-pagination"] button:not(:disabled):hover {
    background-color: var(--ballerina-light);
    color: var(--ballerina-primary);
    border-color: rgba(161, 36, 154, 0.2);
    transform: translateY(-1px);
}

[id$="-pagination"] button:not(:disabled):active {
    transform: translateY(0);
}

/* ==========================================================================
   Filter Select
   ========================================================================== */

.filter-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A1249A' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
    font-family: 'Karla', sans-serif;
    transition: all var(--transition-fast);
}

.filter-select:focus {
    border-color: var(--ballerina-primary);
    box-shadow: 0 0 0 3px var(--ballerina-glow);
}

.filter-select:hover {
    border-color: rgba(161, 36, 154, 0.3);
}

/* ==========================================================================
   Form Elements - Consistent Styling
   ========================================================================== */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
select,
textarea {
    font-family: 'Karla', sans-serif;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
select:focus,
textarea:focus {
    border-color: var(--ballerina-primary);
    box-shadow: 0 0 0 3px var(--ballerina-glow);
    outline: none;
}

/* Enhanced search input glow */
input[type="text"][id$="-search"]:focus {
    box-shadow: 0 0 0 3px var(--ballerina-glow), 0 2px 8px rgba(161, 36, 154, 0.08);
}

/* Range slider styling */
input[type="range"] {
    -webkit-appearance: none;
    height: 8px;
    border-radius: 4px;
    background: #e2e8f0;
    outline: none;
    transition: background var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--ballerina-primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(161, 36, 154, 0.3);
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 10px rgba(161, 36, 154, 0.4);
}

input[type="range"]::-webkit-slider-thumb:active {
    transform: scale(0.95);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--ballerina-primary);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(161, 36, 154, 0.3);
}

/* ==========================================================================
   Gradient Accents
   ========================================================================== */

.gradient-text {
    background: linear-gradient(135deg, var(--ballerina-primary), var(--ballerina-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-border {
    position: relative;
}

.gradient-border::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ballerina-primary), var(--ballerina-secondary));
}

/* ==========================================================================
   Badge / Tags
   ========================================================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    font-family: 'Karla', sans-serif;
    transition: transform var(--transition-fast);
}

.badge:hover {
    transform: scale(1.05);
}

.badge-success {
    background-color: #ecfdf5;
    color: #059669;
}

.badge-warning {
    background-color: #fffbeb;
    color: #d97706;
}

.badge-danger {
    background-color: #fef2f2;
    color: #dc2626;
}

.badge-info {
    background-color: #fdf2fa;
    color: #A1249A;
}

.badge-purple {
    background-color: #f5f3ff;
    color: #0C369C;
}

/* ==========================================================================
   Buttons - Ballerina Style
   ========================================================================== */

button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--ballerina-primary);
    outline-offset: 2px;
}

/* Button press micro-interaction */
button:not(:disabled) {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast),
                background-color var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast), opacity var(--transition-fast);
}

button:not(:disabled):active {
    transform: scale(0.97);
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

.fade-in {
    animation: fadeIn 0.4s ease-out forwards;
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}

.slide-in-left {
    animation: slideInLeft 0.3s ease-out forwards;
}

/* Gentle pulse for loading states */
@keyframes gentlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.gentle-pulse {
    animation: gentlePulse 2s ease-in-out infinite;
}

/* Staggered fade-in for child elements */
@keyframes staggerFadeIn {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stagger-children > * {
    animation: staggerFadeIn 0.4s ease-out both;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.4s; }

/* Float animation for empty states */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* Notification dot pulse */
@keyframes notificationPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(161, 36, 154, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(161, 36, 154, 0); }
}

/* KPI counter animation glow */
.kpi-value.counting {
    color: var(--ballerina-primary);
    transition: color 0.3s ease;
}

.kpi-value.counted {
    color: #0f172a;
    transition: color 0.5s ease;
}

/* ==========================================================================
   Empty States
   ========================================================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fdf2fa, #f3e8ff);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

.empty-state-icon svg {
    width: 36px;
    height: 36px;
    color: var(--ballerina-primary);
    opacity: 0.6;
}

.empty-state-title {
    font-family: 'Quicksand', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.5rem;
}

.empty-state-text {
    font-family: 'Karla', sans-serif;
    font-size: 0.875rem;
    color: #94a3b8;
    max-width: 320px;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.skeleton {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #fdf2fa, #f8fafc);
    border-radius: 8px;
}

.skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.5) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(161, 36, 154, 0.15);
    border-top-color: var(--ballerina-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Chart reveal transition */
.chart-reveal {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

/* Table reveal transition */
.table-reveal {
    opacity: 0;
    transition: opacity var(--transition-slow);
}

/* Table skeleton loading */
.table-skeleton {
    transition: opacity 0.3s ease;
}

/* KPI loading state */
.kpi-loading {
    transition: opacity 0.2s ease;
}

/* ==========================================================================
   Page Background - Botanical accent
   ========================================================================== */

body::before {
    content: '';
    position: fixed;
    top: 0;
    right: 0;
    width: 50%;
    height: 50%;
    background: radial-gradient(ellipse at top right,
        rgba(161, 36, 154, 0.03) 0%,
        rgba(12, 54, 156, 0.02) 30%,
        transparent 70%
    );
    pointer-events: none;
    z-index: 0;
}

/* ==========================================================================
   Chart Responsiveness
   ========================================================================== */

.apexcharts-canvas {
    width: 100% !important;
}

.apexcharts-svg {
    overflow: visible;
}

/* ==========================================================================
   Responsive - Mobile First
   ========================================================================== */

@media (max-width: 639px) {
    .kpi-card {
        padding: 0.875rem;
    }

    .kpi-card .text-2xl {
        font-size: 1.25rem;
    }

    table thead th,
    table tbody td {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    .filter-select {
        font-size: 0.875rem;
    }

    h1.text-2xl {
        font-size: 1.25rem;
    }
}

/* Mobile sidebar */
@media (max-width: 1023px) {
    :root {
        --sidebar-width: 0px;
    }

    aside.mobile-sidebar-closed {
        transform: translateX(-100%);
    }

    aside.mobile-sidebar-open {
        transform: translateX(0);
        width: 260px !important;
    }

    /* Mobile sidebar backdrop blur */
    .fixed.inset-0.z-20 {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }
}

/* Tablet: 768px */
@media (min-width: 768px) and (max-width: 1023px) {
    .kpi-card {
        padding: 1.125rem;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    aside.mobile-sidebar-closed,
    aside.mobile-sidebar-open {
        transform: translateX(0);
    }
}

/* Large screens */
@media (min-width: 1440px) {
    .max-w-7xl {
        max-width: 90rem;
    }
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Glass morphism effect */
.glass {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Hover card lift effect */
.hover-lift {
    transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Chart export button reveal on hover */
.chart-export-btn {
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bg-white:hover .chart-export-btn {
    opacity: 1;
}

/* Additional domain-specific styles from existing extensions */
.inventory-bar {
    height: 24px;
    border-radius: 12px;
    background: #f1f5f9;
    overflow: hidden;
    position: relative;
}

.inventory-bar-fill {
    height: 100%;
    border-radius: 12px;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
}

.inventory-bar-fill.level-healthy {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.inventory-bar-fill.level-medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.inventory-bar-fill.level-low {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.exec-score-cell {
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
    text-align: center;
    min-width: 48px;
    display: inline-block;
}

.exec-score-cell.score-green {
    background: #ecfdf5;
    color: #059669;
}

.exec-score-cell.score-yellow {
    background: #fffbeb;
    color: #d97706;
}

.exec-score-cell.score-red {
    background: #fef2f2;
    color: #dc2626;
}

.delta-indicator {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    font-weight: 600;
}

.delta-up { color: #059669; }
.delta-down { color: #dc2626; }
.delta-neutral { color: #94a3b8; }

.kpi-sparkline {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.kpi-sparkline.loaded {
    opacity: 1;
}

.volatility-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.volatility-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.volatility-low { background: #10b981; }
.volatility-medium { background: #f59e0b; }
.volatility-high { background: #ef4444; }

.cheapest-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: linear-gradient(135deg, #ecfdf5, #d1fae5);
    color: #059669;
    border: 1px solid #a7f3d0;
}

.dos-timeline {
    position: relative;
    height: 8px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: visible;
}

.dos-timeline-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s ease;
}

.dos-timeline-marker {
    position: absolute;
    top: -6px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    border: 3px solid;
    transform: translateX(-50%);
    z-index: 1;
}

/* ==========================================================================
   Design System - Buttons
   ========================================================================== */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Karla', sans-serif;
    color: #ffffff;
    background-color: var(--ballerina-primary);
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(161, 36, 154, 0.2);
}

.btn-primary:hover {
    background-color: var(--ballerina-primary-dark);
    box-shadow: 0 4px 12px rgba(161, 36, 154, 0.25);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0) scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Karla', sans-serif;
    color: #475569;
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    color: var(--ballerina-primary);
    border-color: rgba(161, 36, 154, 0.3);
    background-color: var(--ballerina-light);
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0) scale(0.98);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: 'Karla', sans-serif;
    color: #ffffff;
    background-color: #dc2626;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.2);
}

.btn-danger:hover {
    background-color: #b91c1c;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
    transform: translateY(-1px);
}

.btn-danger:active {
    transform: translateY(0) scale(0.98);
}

/* Button sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-md {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* ==========================================================================
   Design System - Cards
   ========================================================================== */

.card {
    background-color: var(--bg-card);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(161, 36, 154, 0.08);
    overflow: hidden;
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.card-hover {
    cursor: default;
}

.card-hover:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-accent-pink {
    border-top: 3px solid var(--ballerina-primary);
}

.card-accent-purple {
    border-top: 3px solid var(--ballerina-secondary);
}

.card-accent-green {
    border-top: 3px solid #10b981;
}

.card-accent-blue {
    border-top: 3px solid #3b82f6;
}

.card-accent-amber {
    border-top: 3px solid #f59e0b;
}

/* ==========================================================================
   Design System - Typography Utilities
   ========================================================================== */

.text-label {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    font-family: 'Karla', sans-serif;
}

.text-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Quicksand', sans-serif;
    line-height: 1.2;
}

.text-value-sm {
    font-size: 1.125rem;
    font-weight: 700;
    color: #0f172a;
    font-family: 'Quicksand', sans-serif;
    line-height: 1.2;
}

.text-change-positive {
    color: #059669;
    font-family: 'Karla', sans-serif;
}

.text-change-positive::before {
    content: '\25B2 ';
    font-size: 0.65em;
}

.text-change-negative {
    color: #dc2626;
    font-family: 'Karla', sans-serif;
}

.text-change-negative::before {
    content: '\25BC ';
    font-size: 0.65em;
}

/* ==========================================================================
   Design System - Spacing
   ========================================================================== */

.section-gap {
    margin-bottom: 1.5rem;
}

.card-gap {
    gap: 1rem;
}

/* ==========================================================================
   Design System - Transitions
   ========================================================================== */

.transition-card {
    transition: box-shadow var(--transition-base),
                transform var(--transition-base),
                border-color var(--transition-base);
}

.transition-fade {
    transition: opacity var(--transition-base);
}

/* ==========================================================================
   Design System - Badge Neutral Variant
   ========================================================================== */

.badge-neutral {
    background-color: #f1f5f9;
    color: #64748b;
}

/* ==========================================================================
   Design System - Tab Navigation
   ========================================================================== */

.tab-nav {
    border-bottom: 1px solid #e2e8f0;
}

.tab-item {
    white-space: nowrap;
    font-family: 'Karla', sans-serif;
}

/* ==========================================================================
   Design System - Alert Banners
   ========================================================================== */

.alert-banner {
    font-family: 'Karla', sans-serif;
}

/* ==========================================================================
   Tooltip System
   ========================================================================== */

.tooltip-popup {
    position: fixed;
    background: #0f172a;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: 'Karla', sans-serif;
    z-index: 9999;
    pointer-events: none;
    white-space: nowrap;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: tooltipFadeIn 0.15s ease-out;
    line-height: 1.4;
}

.tooltip-popup.tooltip-multiline {
    white-space: normal;
}

.tooltip-popup::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #0f172a;
}

.tooltip-popup.tooltip-bottom::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #0f172a;
}

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

/* ==========================================================================
   Modal System
   ========================================================================== */

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 50;
    animation: modalBackdropIn 0.2s ease-out;
}

@keyframes modalBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    position: fixed;
    inset: 0;
    z-index: 51;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-panel {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-height: 85vh;
    overflow-y: auto;
    width: 100%;
    animation: modalSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-panel-sm { max-width: 24rem; }
.modal-panel-md { max-width: 32rem; }
.modal-panel-lg { max-width: 56rem; }
.modal-panel-xl { max-width: 72rem; }

.modal-header {
    position: sticky;
    top: 0;
    background: white;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 1rem 1rem 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1;
}

.modal-header h3 {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.125rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    color: #94a3b8;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    background: none;
}

.modal-close-btn:hover {
    color: #475569;
    background: #f1f5f9;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==========================================================================
   Toast Notification System
   ========================================================================== */

#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9998;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-family: 'Karla', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);
    pointer-events: auto;
    animation: toastSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 380px;
    border: 1px solid transparent;
}

.toast.toast-exiting {
    animation: toastSlideOut 0.2s ease-in forwards;
}

.toast-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.toast-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.toast-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.toast-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

@keyframes toastSlideIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toastSlideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

/* ==========================================================================
   Info Icon Button
   ========================================================================== */

.info-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #94a3b8;
    border: none;
    cursor: help;
    transition: all var(--transition-fast);
    vertical-align: middle;
    margin-left: 0.25rem;
    flex-shrink: 0;
}

.info-icon-btn:hover {
    background: var(--ballerina-light);
    color: var(--ballerina-primary);
}

.info-icon-btn svg {
    width: 0.75rem;
    height: 0.75rem;
}

/* ==========================================================================
   Chain / Brand Logos & Badges
   ========================================================================== */

.chain-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.chain-logo {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 0.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    font-family: 'Karla', sans-serif;
}

/* ==========================================================================
   Status Badges (enhanced)
   ========================================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: 'Karla', sans-serif;
    border: 1px solid transparent;
}

.status-badge-ok {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.status-badge-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}

.status-badge-critical {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.status-badge-info {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.status-badge-neutral {
    background: #f8fafc;
    color: #475569;
    border-color: #e2e8f0;
}

/* ==========================================================================
   Enhanced Table Rows
   ========================================================================== */

table tbody tr.row-clickable {
    cursor: pointer;
}

table tbody tr.row-clickable:hover {
    background-color: rgba(161, 36, 154, 0.04) !important;
}

table tbody tr.row-selected {
    background-color: rgba(161, 36, 154, 0.06) !important;
}

/* Row actions dropdown */
.row-actions-menu {
    position: absolute;
    right: 0.5rem;
    top: 100%;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    border: 1px solid #e2e8f0;
    z-index: 40;
    min-width: 140px;
    padding: 0.25rem;
    animation: tooltipFadeIn 0.15s ease-out;
}

.row-actions-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: #475569;
    border: none;
    background: none;
    cursor: pointer;
    border-radius: 0.375rem;
    transition: all var(--transition-fast);
    font-family: 'Karla', sans-serif;
}

.row-actions-menu button:hover {
    background: var(--ballerina-light);
    color: var(--ballerina-primary);
}

/* ==========================================================================
   Chart Card Enhancements
   ========================================================================== */

.chart-source-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 500;
    background: #f8fafc;
    color: #94a3b8;
    border: 1px solid #e2e8f0;
    font-family: 'Karla', sans-serif;
}

.chart-fullscreen-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: white;
    padding: 1.5rem;
    animation: modalSlideIn 0.25s ease-out;
}

.chart-fullscreen-overlay .chart-fullscreen-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 51;
}

/* ==========================================================================
   Enhanced Sidebar
   ========================================================================== */

.sidebar-nav-item:hover {
    transform: translateX(3px);
}

.sidebar-section-label {
    padding: 0.5rem 0.75rem 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    font-family: 'Karla', sans-serif;
}

.sidebar-notification-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #ef4444;
    position: absolute;
    top: 8px;
    right: 8px;
    animation: notificationPulse 2s ease-in-out infinite;
}

.sidebar-user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user-avatar {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ballerina-primary), #0C369C);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* ==========================================================================
   Trend Arrow Pulse
   ========================================================================== */

.trend-pulse {
    animation: trendPulse 1.5s ease-in-out 3;
}

@keyframes trendPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==========================================================================
   Print
   ========================================================================== */

@media print {
    aside,
    header,
    .filter-bar,
    button {
        display: none !important;
    }

    main {
        margin-left: 0 !important;
        padding: 0 !important;
        animation: none !important;
    }

    .kpi-card,
    .bg-white {
        box-shadow: none !important;
        border: 1px solid #e2e8f0 !important;
    }

    body {
        background: white !important;
    }

    body::before {
        display: none;
    }

    table tbody tr:nth-child(even) {
        background-color: #f8fafc !important;
    }
}
