/* ============================================================
   XI ROYALE — Canvas Theme: Component Styles
   ─────────────────────────────────────────────
   All color VARIABLES live in design-tokens.css (the single
   source of truth). This file only defines component styles
   that consume those variables via var(--*).
   ============================================================ */

/* NOTE: Variables are loaded from css/design-tokens.css */


/* ---------- GLOBAL CANVAS THEME STYLES ---------- */
body.xi-canvas-theme {
    background-color: var(--bg-primary) !important;
    background-image: none !important;
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Remove old dark theme pseudo elements */
body.xi-canvas-theme::before,
body.xi-canvas-theme::after {
    display: none !important;
}

/* Canvas layer */
#xi-canvas-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}


/* ---------- CARD SYSTEM ---------- */
body.xi-canvas-theme .xi-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
}

body.xi-canvas-theme .xi-card:hover {
    box-shadow: var(--shadow-card-hover);
    border-color: var(--border-medium);
}

body.xi-canvas-theme .xi-card-inner {
    background: var(--bg-card-inner);
    border-radius: 12px;
    padding: 12px;
}

/* Override the old premium-card class */
body.xi-canvas-theme .premium-card {
    background: var(--bg-card) !important;
    border: 1px solid var(--border-light) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow-card) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body.xi-canvas-theme .premium-card:hover {
    box-shadow: var(--shadow-card-hover) !important;
    border-color: var(--border-medium) !important;
    transform: translateY(-1px);
}


/* ---------- TEXT OVERRIDES ---------- */
body.xi-canvas-theme .text-slate-900,
body.xi-canvas-theme .text-white {
    color: var(--text-primary) !important;
}

body.xi-canvas-theme .text-slate-500,
body.xi-canvas-theme .text-slate-400 {
    color: var(--text-secondary) !important;
}

body.xi-canvas-theme .text-white\/50,
body.xi-canvas-theme .text-white\/40,
body.xi-canvas-theme .text-white\/30 {
    color: var(--text-tertiary) !important;
}

/* Keep brand colors */
body.xi-canvas-theme .text-primary {
    color: var(--brand) !important;
}


/* ---------- BACKGROUND OVERRIDES ---------- */
body.xi-canvas-theme .bg-white {
    background-color: var(--bg-card) !important;
}

body.xi-canvas-theme .bg-slate-50 {
    background-color: var(--bg-card-inner) !important;
}

body.xi-canvas-theme .bg-white\/5,
body.xi-canvas-theme .bg-white\/10 {
    background-color: var(--bg-card-inner) !important;
}


/* ---------- BORDER OVERRIDES ---------- */
body.xi-canvas-theme .border-slate-200,
body.xi-canvas-theme .border-slate-100,
body.xi-canvas-theme .border-white\/5,
body.xi-canvas-theme .border-white\/10,
body.xi-canvas-theme .border-white\/8 {
    border-color: var(--border-light) !important;
}


/* ---------- WELCOME SECTION ---------- */
body.xi-canvas-theme .xi-welcome {
    padding: 16px 20px;
}

body.xi-canvas-theme .xi-welcome-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

body.xi-canvas-theme .xi-welcome-name {
    font-family: 'Space Grotesk', 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
    line-height: 1.2;
}

body.xi-canvas-theme .xi-welcome-rank {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

body.xi-canvas-theme .xi-welcome-rank .rank-change {
    color: var(--success);
    font-weight: 700;
}


/* ---------- SEASON BANNER ---------- */
body.xi-canvas-theme .xi-season-banner {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-radius: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #FFFFFF;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

body.xi-canvas-theme .xi-season-banner::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    pointer-events: none;
}

body.xi-canvas-theme .xi-season-banner-icon {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

body.xi-canvas-theme .xi-season-banner-text {
    flex: 1;
    min-width: 0;
}

body.xi-canvas-theme .xi-season-banner-title {
    font-weight: 800;
    font-size: 12px;
    letter-spacing: 0.03em;
}

body.xi-canvas-theme .xi-season-banner-desc {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}


/* ---------- ARENA CARD ---------- */
body.xi-canvas-theme .xi-arena-card {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    min-height: 200px;
    box-shadow: var(--shadow-elevated);
    z-index: 1;
}

body.xi-canvas-theme .xi-arena-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center 30%;
    z-index: 0;
}

body.xi-canvas-theme .xi-arena-overlay {
    position: absolute;
    inset: 0;
    background: var(--arena-overlay);
    z-index: 1;
}

body.xi-canvas-theme .xi-arena-content {
    position: relative;
    z-index: 2;
    height: 100%;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #FFFFFF;
}

body.xi-canvas-theme .xi-arena-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 700;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: fit-content;
}

body.xi-canvas-theme .xi-arena-badge .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--brand);
}

body.xi-canvas-theme .xi-arena-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 28px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: -0.02em;
    line-height: 1;
    margin-top: 8px;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

body.xi-canvas-theme .xi-arena-subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.7;
    margin-top: 4px;
}

body.xi-canvas-theme .xi-arena-status {
    font-size: 11px;
    font-weight: 800;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-top: 2px;
}

body.xi-canvas-theme .xi-arena-stats {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
}

body.xi-canvas-theme .xi-arena-stat {
    flex: 1;
    padding: 8px 6px;
    text-align: center;
    position: relative;
    min-width: 0;
}

body.xi-canvas-theme .xi-arena-stat:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 20%;
    height: 60%;
    width: 1px;
    background: rgba(255, 255, 255, 0.15);
}

body.xi-canvas-theme .xi-arena-stat-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.6;
}

body.xi-canvas-theme .xi-arena-stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 800;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.xi-canvas-theme .xi-arena-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--brand);
    color: #FFFFFF;
    font-weight: 800;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 12px;
    border-radius: 12px;
    margin-top: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
    width: 100%;
}

body.xi-canvas-theme .xi-arena-cta:hover {
    background: var(--brand-dark);
    transform: translateY(-1px);
}


/* ---------- TWO-COLUMN STATS GRID ---------- */
body.xi-canvas-theme .xi-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    z-index: 1;
    position: relative;
}

@media (max-width: 360px) {
    body.xi-canvas-theme .xi-stats-grid {
        grid-template-columns: 1fr;
    }
}


/* ---------- YOUR TEAM CARD ---------- */
body.xi-canvas-theme .xi-team-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-card);
}

body.xi-canvas-theme .xi-team-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

body.xi-canvas-theme .xi-team-card-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body.xi-canvas-theme .xi-team-stat {
    text-align: center;
}

body.xi-canvas-theme .xi-team-stat-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

body.xi-canvas-theme .xi-team-stat-label.accent {
    color: var(--brand);
}

body.xi-canvas-theme .xi-team-stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: clamp(12px, 4.5vw, 20px);
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 2px;
    letter-spacing: -0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.xi-canvas-theme .xi-team-sparkline {
    height: 24px;
    margin-top: 4px;
}


/* ---------- OPEN BATTLES CARD ---------- */
body.xi-canvas-theme .xi-battles-card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    box-shadow: var(--shadow-card);
}

body.xi-canvas-theme .xi-battles-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

body.xi-canvas-theme .xi-battles-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body.xi-canvas-theme .xi-battles-viewall {
    font-size: 11px;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
    text-decoration: none;
}

body.xi-canvas-theme .xi-battle-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

body.xi-canvas-theme .xi-battle-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

body.xi-canvas-theme .xi-battle-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-card-inner);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
    overflow: hidden;
}

body.xi-canvas-theme .xi-battle-info {
    flex: 1;
    min-width: 0;
}

body.xi-canvas-theme .xi-battle-opponent {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
}

body.xi-canvas-theme .xi-battle-score {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 800;
    color: var(--text-primary);
}

body.xi-canvas-theme .xi-battle-status {
    font-size: 9px;
    font-weight: 700;
}

body.xi-canvas-theme .xi-battle-status.winning {
    color: var(--success);
}

body.xi-canvas-theme .xi-battle-status.losing {
    color: var(--danger);
}

body.xi-canvas-theme .xi-battle-status.draw {
    color: var(--text-tertiary);
}

body.xi-canvas-theme .xi-battle-time {
    font-size: 9px;
    color: var(--text-tertiary);
    font-weight: 600;
}

body.xi-canvas-theme .xi-battle-create {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 0 2px;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand);
    cursor: pointer;
}


/* ---------- KE RANK BADGE ---------- */
body.xi-canvas-theme .xi-rank-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: var(--shadow-card);
    z-index: 1;
    position: relative;
}

body.xi-canvas-theme .xi-rank-badge-icon {
    font-size: 18px;
}

body.xi-canvas-theme .xi-rank-badge-text {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

body.xi-canvas-theme .xi-rank-badge-text strong {
    color: var(--text-primary);
    font-weight: 800;
}

body.xi-canvas-theme .xi-rank-badge-arrow {
    color: var(--text-tertiary);
    font-size: 12px;
}


/* ---------- FPL WRAPPED BANNER ---------- */
body.xi-canvas-theme .xi-wrapped-banner {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-card);
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

body.xi-canvas-theme .xi-wrapped-content {
    flex: 1;
}

body.xi-canvas-theme .xi-wrapped-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: -0.01em;
}

body.xi-canvas-theme .xi-wrapped-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

body.xi-canvas-theme .xi-wrapped-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand);
    margin-top: 8px;
    text-decoration: none;
    cursor: pointer;
}

body.xi-canvas-theme .xi-wrapped-visual {
    width: 80px;
    height: 80px;
    flex-shrink: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--brand-bg), var(--brand-bg-strong));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
}


/* ---------- HEADER (MOBILE) ---------- */
body.xi-canvas-theme .xi-header-mobile {
    background: var(--header-bg) !important;
    border: 1px solid var(--header-border) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}

body.xi-canvas-theme .xi-header-mobile .xi-header-btn {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}


/* ---------- BOTTOM NAV ---------- */
body.xi-canvas-theme .xi-bottom-nav {
    background: var(--nav-bg) !important;
    border-top: 1px solid var(--nav-border) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06) !important;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon {
    color: var(--nav-icon) !important;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon.active {
    color: var(--nav-icon-active) !important;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon span {
    color: inherit !important;
}

body.xi-canvas-theme .xi-bottom-nav .xi-fab-btn {
    background: var(--brand) !important;
    border: 4px solid var(--bg-primary) !important;
    box-shadow: 0 4px 20px rgba(0, 210, 190, 0.35) !important;
}


/* ---------- DRAWER ---------- */
body.xi-canvas-theme #side-drawer {
    background: var(--drawer-bg) !important;
    border-right: 1px solid var(--drawer-border) !important;
}

body.xi-canvas-theme #side-drawer a {
    color: var(--text-secondary);
}

body.xi-canvas-theme #side-drawer a:hover {
    background: var(--bg-card-inner);
}


/* ---------- QUICK ACTIONS ---------- */
body.xi-canvas-theme .xi-quick-action {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow-card);
    transition: all 0.3s ease;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

body.xi-canvas-theme .xi-quick-action:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-card-hover);
}

body.xi-canvas-theme .xi-quick-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    font-size: 18px;
}


/* ---------- DESKTOP SIDEBAR ---------- */
body.xi-canvas-theme #ds-left-sidebar-dashboard {
    border-right-color: var(--border-light) !important;
}

body.xi-canvas-theme #ds-left-sidebar-dashboard a {
    color: var(--text-secondary) !important;
}

body.xi-canvas-theme #ds-left-sidebar-dashboard a:hover {
    background: var(--bg-card-inner) !important;
}


/* ---------- ANIMATIONS ---------- */
@keyframes xi-fade-up {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.xi-canvas-theme .xi-animate-in {
    animation: xi-fade-up 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

body.xi-canvas-theme .xi-delay-1 { animation-delay: 0.05s; }
body.xi-canvas-theme .xi-delay-2 { animation-delay: 0.1s; }
body.xi-canvas-theme .xi-delay-3 { animation-delay: 0.15s; }
body.xi-canvas-theme .xi-delay-4 { animation-delay: 0.2s; }
body.xi-canvas-theme .xi-delay-5 { animation-delay: 0.25s; }
body.xi-canvas-theme .xi-delay-6 { animation-delay: 0.3s; }


/* ---------- REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
    body.xi-canvas-theme .xi-animate-in {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
    
    body.xi-canvas-theme .premium-card,
    body.xi-canvas-theme .xi-card {
        transition: none !important;
    }
}


/* ---------- RESPONSIVE ---------- */
@media (min-width: 1024px) {
    body.xi-canvas-theme .xi-arena-card {
        min-height: 260px;
    }
    
    body.xi-canvas-theme .xi-arena-title {
        font-size: 36px;
    }

    body.xi-canvas-theme .xi-arena-stat-value {
        font-size: 14px;
    }

    body.xi-canvas-theme .xi-arena-stat {
        padding: 10px 12px;
    }
}

/* ---------- CAPTAIN WELCOME CARD ---------- */
body.xi-canvas-theme .xi-captain-c-frame-1 {
    border: 3px solid var(--brand);
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-radius: 50%;
    transform: rotate(-15deg);
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body.xi-canvas-theme .xi-captain-c-frame-2 {
    border: 2px solid var(--brand);
    border-left-color: transparent;
    border-top-color: transparent;
    border-radius: 50%;
    transform: rotate(15deg);
    opacity: 0.4;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hover effects for the frames */
body.xi-canvas-theme .xi-card:hover .xi-captain-c-frame-1 {
    transform: rotate(-5deg) scale(1.02);
}

body.xi-canvas-theme .xi-card:hover .xi-captain-c-frame-2 {
    transform: rotate(5deg) scale(0.98);
    opacity: 0.7;
}


/* ---------- BOTTOM NAV READABILITY FIX ---------- */
/* Ensures nav labels and FAB button adapt to theme */
body.xi-canvas-theme .xi-bottom-nav .nav-icon {
    color: var(--nav-icon) !important;
    transition: color 0.2s ease;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon.active {
    color: var(--nav-icon-active) !important;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon span {
    color: inherit !important;
}

body.xi-canvas-theme .xi-bottom-nav .nav-icon.active span {
    color: var(--nav-label-active) !important;
}

/* Fix FAB button border — was hardcoded to #1a1a1a */
body.xi-canvas-theme .xi-bottom-nav button[class*="border-"] {
    border-color: var(--bg-primary) !important;
}


/* ---------- HARDCODED DARK BACKGROUND CATCHERS ---------- */
/* Safety net: Override common hardcoded dark backgrounds */
body.xi-canvas-theme {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Override hardcoded backgrounds on common wrapper divs */
body.xi-canvas-theme > div[style*="background: #1a1a1a"],
body.xi-canvas-theme > div[style*="background-color: #1a1a1a"],
body.xi-canvas-theme > div[style*="background: #0F0F0F"],
body.xi-canvas-theme > div[style*="background: #0a0a0a"],
body.xi-canvas-theme > div[style*="background: #111"] {
    background-color: var(--bg-primary) !important;
}

/* Common bottom-nav variants used across pages */
body.xi-canvas-theme .bottom-nav-premium {
    background: var(--nav-bg) !important;
    border-top: 1px solid var(--nav-border) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
}
