/* ============================================================
   FPL Companion — custom design system
   ============================================================ */
:root {
    --fpl-purple: #37003c;
    --fpl-purple-light: #4f0153;
    --fpl-purple-dark: #1f0023;
    --fpl-green: #00ff87;
    --fpl-pink: #e90052;
    --fpl-cyan: #02efff;
    --fpl-yellow: #ebff00;
    --fpl-gold: #d4af37;
    --fpl-gold-light: #fce884;
    --fpl-gold-dark: #a07e1c;

    --bg: #f4f4f7;
    --bg-card: #ffffff;
    --bg-soft: #f9f9fb;
    --text: #1a1a23;
    --text-muted: #6c757d;
    --border: #e8e8ee;
    --border-light: #f0f0f5;

    --shadow-sm: 0 1px 3px rgba(55, 0, 60, 0.05);
    --shadow: 0 4px 12px rgba(55, 0, 60, 0.06);
    --shadow-lg: 0 10px 32px rgba(55, 0, 60, 0.08);

    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-feature-settings: 'cv11', 'ss01';
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; letter-spacing: -0.02em; }

/* ---- Navbar ---- */
.navbar-fpl {
    background: linear-gradient(135deg, var(--fpl-purple) 0%, var(--fpl-purple-light) 100%);
    box-shadow: var(--shadow);
    padding: 0.75rem 0;
}
.navbar-fpl .navbar-brand {
    color: #fff !important;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.03em;
}
/* Hamburger toggle (mobile) — Bootstrap defaults use a dark SVG that's invisible
   on our purple navbar. Override with a white version + visible border. */
.navbar-fpl .navbar-toggler {
    border: 1px solid rgba(255,255,255,0.25);
    padding: 0.35rem 0.6rem;
    border-radius: 8px;
    color: #fff;
}
.navbar-fpl .navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(0,255,135,0.35);
    outline: none;
}
.navbar-fpl .navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cpath stroke='rgba%28255,255,255,0.9%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2.5' d='M4 7h22M4 15h22M4 23h22'/%3E%3C/svg%3E");
    width: 22px;
    height: 22px;
}

.navbar-fpl .brand-logo {
    width: 32px; height: 32px;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.25));
    transition: transform 0.3s ease;
}
.navbar-fpl .navbar-brand:hover .brand-logo { transform: rotate(15deg) scale(1.05); }
.navbar-fpl .brand-text {
    font-weight: 800;
    letter-spacing: -0.02em;
}
.navbar-fpl .brand-text-accent {
    color: var(--fpl-gold);
    font-weight: 400;
    font-style: italic;
}
.navbar-fpl .nav-link {
    color: rgba(255,255,255,0.75) !important;
    font-weight: 500;
    font-size: 0.88rem;
    padding: 0.45rem 0.7rem !important;
    border-radius: 8px;
    transition: all 0.15s;
    margin: 0 1px;
    white-space: nowrap;            /* prevent labels like "Mini-League" wrapping */
}
@media (min-width: 992px) and (max-width: 1199px) {
    /* Slightly tighter on medium-desktop so the row doesn't wrap */
    .navbar-fpl .nav-link { padding: 0.4rem 0.55rem !important; font-size: 0.85rem; }
    .navbar-fpl .brand-text { font-size: 1.05rem; }
}
@media (max-width: 991px) {
    /* Mobile: navbar collapses to vertical via Bootstrap's toggler */
    .navbar-fpl .nav-link { padding: 0.55rem 0.8rem !important; margin: 1px 0; }
}
.navbar-fpl .nav-link:hover {
    color: #fff !important;
    background: rgba(255,255,255,0.08);
}
.navbar-fpl .nav-link.active {
    color: var(--fpl-purple) !important;
    background: var(--fpl-green);
    font-weight: 600;
}
/* Dropdown styling for the Tools menu */
.navbar-fpl .dropdown-toggle::after { margin-left: 4px; }
.navbar-fpl .dropdown-menu {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 0.4rem 0;
    margin-top: 4px;
}
.navbar-fpl .dropdown-item {
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    color: var(--text);
}
.navbar-fpl .dropdown-item:hover,
.navbar-fpl .dropdown-item:focus {
    background: var(--bg-soft);
    color: var(--fpl-purple);
}
.navbar-fpl .dropdown-item.active {
    background: var(--fpl-purple);
    color: #fff;
}
.navbar-fpl .dropdown-item i {
    width: 18px;
    color: var(--fpl-purple);
    margin-right: 4px;
}
.navbar-fpl .dropdown-item.active i { color: var(--fpl-green); }

/* ---- Cards ---- */
.card {
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--bg-card);
    transition: box-shadow 0.2s, transform 0.2s;
}
.card.hover-lift:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}
.card-header {
    background: var(--bg-card) !important;
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 1.25rem;
    font-weight: 600;
    border-radius: var(--radius) var(--radius) 0 0 !important;
}
.card-body { padding: 1.25rem; }

.stat-card {
    border: none;
    border-left: 3px solid var(--fpl-pink);
    background: linear-gradient(135deg, #ffffff 0%, var(--bg-soft) 100%);
}
.stat-card .stat-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.25rem;
}
.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
}
.stat-card .stat-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ---- Hero ---- */
.hero {
    background: linear-gradient(135deg, var(--fpl-purple) 0%, var(--fpl-purple-light) 60%, var(--fpl-pink) 140%);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}
.hero::before {
    content: '';
    position: absolute;
    top: -50%; right: -10%;
    width: 60%; height: 200%;
    background: radial-gradient(circle, rgba(0,255,135,0.15) 0%, transparent 70%);
    pointer-events: none;
}
.hero h1 { font-size: 1.8rem; font-weight: 800; margin: 0; }
.hero .hero-subtitle { opacity: 0.85; font-size: 0.95rem; }
.hero-gw-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 0.35rem 0.75rem;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}
.hero-live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--fpl-green);
    box-shadow: 0 0 0 0 rgba(0,255,135,0.7);
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(0,255,135,0.7); }
    70% { box-shadow: 0 0 0 10px rgba(0,255,135,0); }
    100% { box-shadow: 0 0 0 0 rgba(0,255,135,0); }
}

/* ---- Position badges ---- */
.pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    min-width: 32px;
}
.pos-GKP { background: var(--fpl-yellow); color: #1a1a23; }
.pos-DEF { background: var(--fpl-green); color: #1a1a23; }
.pos-MID { background: var(--fpl-cyan); color: #1a1a23; }
.pos-FWD { background: #ff9ab8; color: #1a1a23; }

/* ---- FDR cells ---- */
.fdr-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    min-width: 64px;
    margin: 1px;
    line-height: 1.3;
}
.fdr-1 { background: #257d54; color: #fff; }
.fdr-2 { background: #01fc7a; color: #1a1a23; }
.fdr-3 { background: #e8e8ee; color: #525252; }
.fdr-4 { background: #ff1751; color: #fff; }
.fdr-5 { background: #80072d; color: #fff; }

/* ---- Tables ---- */
.table {
    margin-bottom: 0;
    font-size: 0.88rem;
}
.table > :not(caption) > * > * { padding: 0.6rem 0.75rem; }
.table-hover > tbody > tr:hover { background-color: rgba(55,0,60,0.03); }
.table thead th {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    background: var(--bg-soft) !important;
}

/* ---- Buttons ---- */
.btn { font-weight: 500; border-radius: var(--radius-sm); }
.btn-dark {
    background: var(--fpl-purple);
    border-color: var(--fpl-purple);
}
.btn-dark:hover, .btn-dark:focus {
    background: var(--fpl-purple-light);
    border-color: var(--fpl-purple-light);
}
.btn-outline-dark {
    color: var(--fpl-purple);
    border-color: var(--fpl-purple);
}
.btn-outline-dark:hover { background: var(--fpl-purple); border-color: var(--fpl-purple); }

/* ---- Live indicator ---- */
.live-pulse {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--fpl-pink);
}
.live-pulse::before {
    content: '';
    width: 8px; height: 8px;
    background: var(--fpl-pink);
    border-radius: 50%;
    animation: livePulse 1.5s infinite;
}
@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.2); }
}
.live-points-badge {
    background: linear-gradient(135deg, var(--fpl-pink) 0%, #ff3b73 100%);
    color: #fff;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* ---- Pitch (for Best XI) ---- */
.pitch {
    background: linear-gradient(180deg, #0d8043 0%, #0a6936 100%);
    background-image:
        repeating-linear-gradient(0deg, transparent 0, transparent 39px, rgba(255,255,255,0.05) 39px, rgba(255,255,255,0.05) 40px),
        linear-gradient(180deg, #0d8043 0%, #0a6936 100%);
    border-radius: var(--radius);
    padding: 1.5rem 0.5rem;
    position: relative;
    min-height: 600px;
    border: 3px solid #0a6936;
}
.pitch-row {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}
.pitch-player {
    flex: 0 0 92px;        /* fixed width = aligns cards & name pills */
    width: 92px;
    text-align: center;
    color: #fff;
    position: relative;
    padding-top: 8px;
}
/* Player card — photo on top + team strip on bottom, like an FPL card */
.pitch-player .player-card {
    width: 72px;
    height: 92px;
    margin: 0 auto 8px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0,0,0,0.35);
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, #ffffff 0%, #ebebf2 100%);
    position: relative;
}
.pitch-player .player-photo {
    width: 100%;
    height: 72px;
    object-fit: cover;
    object-position: center top;
    background: #d9d9e3;
    display: block;
    flex-shrink: 0;
}
.pitch-player .player-fallback {
    width: 100%;
    height: 72px;
    background: linear-gradient(135deg, #37003c 0%, #4f0153 100%);
    color: #00ff87;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: -0.02em;
    flex-shrink: 0;
}
.pitch-player .player-card-footer {
    background: var(--fpl-green);
    color: var(--fpl-purple);
    font-size: 0.65rem;
    font-weight: 800;
    text-align: center;
    padding: 3px 2px;
    line-height: 1.2;
    letter-spacing: 0.04em;
    margin-top: auto;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Player name pill — sits below the card, fixed-width to align with card edges */
.pitch-player .name {
    display: block;
    width: 88px;
    margin: 0 auto 3px;
    font-size: 0.72rem;
    font-weight: 600;
    background: rgba(0,0,0,0.72);
    padding: 3px 4px;
    border-radius: 4px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* EP meta — small green pill below the name */
.pitch-player .meta {
    display: inline-block;
    font-size: 0.68rem;
    background: var(--fpl-green);
    color: var(--fpl-purple);
    padding: 1px 8px;
    border-radius: 4px;
    font-weight: 800;
    letter-spacing: -0.01em;
    line-height: 1.4;
}
.pitch-player .captain {
    position: absolute;
    top: 2px;
    right: 6px;
    background: var(--fpl-yellow);
    color: #1a1a23;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    z-index: 2;
    border: 2px solid #fff;
}

/* ---- Misc ---- */
.text-fpl-purple { color: var(--fpl-purple); }
.text-fpl-green { color: var(--fpl-green); }
.bg-fpl-purple { background: var(--fpl-purple); color: #fff; }
.bg-soft { background: var(--bg-soft); }

.section-title {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.player-row {
    transition: background 0.15s;
}
.player-row:hover .player-name { color: var(--fpl-pink); }

.player-name {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.divider-soft {
    height: 1px;
    background: var(--border-light);
    margin: 1rem 0;
}

/* Tabs */
.nav-tabs {
    border-bottom: 1px solid var(--border);
}
.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 0.6rem 1rem;
    border-radius: 0;
    border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link:hover {
    color: var(--fpl-purple);
    border-bottom-color: var(--border);
}
.nav-tabs .nav-link.active {
    color: var(--fpl-purple);
    background: transparent;
    border-bottom-color: var(--fpl-purple);
    font-weight: 600;
}

/* Alerts */
.alert {
    border: none;
    border-radius: var(--radius-sm);
    border-left: 3px solid;
    font-size: 0.92rem;
    padding: 0.75rem 1rem;
}
.alert-info { background: #eaf6ff; color: #0d4f8a; border-left-color: #2196f3; }
.alert-success { background: #e6fff3; color: #0f5e2c; border-left-color: var(--fpl-green); }
.alert-warning { background: #fff8e0; color: #5a4500; border-left-color: #ffc107; }
.alert-danger { background: #ffeaef; color: #8a1c2e; border-left-color: var(--fpl-pink); }
.alert-light { background: #fff; }
.alert-secondary { background: var(--bg-soft); color: var(--text); border-left-color: var(--border); }

/* Form controls */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border);
    font-size: 0.92rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--fpl-purple-light);
    box-shadow: 0 0 0 3px rgba(55,0,60,0.1);
}

/* Set-piece badges */
.sp-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 800;
    margin: 0 1px;
}
.sp-pen { background: #ffc107; color: #5a4500; }
.sp-fk  { background: var(--fpl-cyan); color: #003e44; }
.sp-cor { background: #e8e8ee; color: #525252; }

/* Footer */
footer.app-footer {
    margin-top: 4rem;
    padding: 2rem 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border-light);
}

/* Mobile */
@media (max-width: 768px) {
    .hero { padding: 1.25rem; }
    .hero h1 { font-size: 1.4rem; }
    .stat-card .stat-value { font-size: 1.3rem; }
    .pitch-player { flex-basis: 75px; }
    .pitch-player .jersey { width: 40px; height: 50px; font-size: 0.7rem; }
}
