/* ============================================================
   LOI Fantasy Football - Main Stylesheet
   Mobile-first, lightweight, shared hosting friendly
   ============================================================ */

:root {
    --primary: #1a5e1f;
    --primary-light: #2d8a33;
    --primary-dark: #0e3d12;
    --accent: #f59e0b;
    --accent-light: #fbbf24;
    --bg: #f3f4f6;
    --bg-white: #ffffff;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --gk: #f59e0b;
    --def: #3b82f6;
    --mid: #10b981;
    --fwd: #ef4444;
    --shadow: 0 1px 3px rgba(0,0,0,.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,.1);
    --radius: 8px;
    --radius-lg: 12px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); text-decoration: underline; }

img { max-width: 100%; height: auto; }

/* Layout */
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 600px; margin: 0 auto; padding: 0 1rem; }
.container-md { max-width: 800px; margin: 0 auto; padding: 0 1rem; }

/* ============================================================
   HEADER / NAVIGATION
   ============================================================ */
.site-header {
    background: var(--primary-dark);
    color: white;
    padding: .75rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.site-logo:hover { color: var(--accent); text-decoration: none; }
.site-logo span { color: var(--accent); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem;
}

.main-nav { display: flex; align-items: center; gap: .25rem; }

.main-nav a, .main-nav button {
    color: rgba(255,255,255,.85);
    padding: .5rem .75rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    transition: all .2s;
    border: none;
    background: none;
    cursor: pointer;
    white-space: nowrap;
}
.main-nav a:hover, .main-nav button:hover,
.main-nav a.active { 
    background: rgba(255,255,255,.15); 
    color: white; 
    text-decoration: none; 
}

.nav-user {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: .5rem;
    padding-left: .5rem;
    border-left: 1px solid rgba(255,255,255,.2);
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }
    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--primary-dark);
        flex-direction: column;
        padding: .5rem;
        box-shadow: var(--shadow-md);
    }
    .main-nav.open { display: flex; }
    .main-nav a, .main-nav button { width: 100%; text-align: left; padding: .75rem 1rem; }
    .nav-user { margin: 0; padding: .5rem 0 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.2); }
}

/* ============================================================
   BANNER
   ============================================================ */
.banner {
    padding: .75rem 1rem;
    text-align: center;
    font-weight: 500;
    font-size: .875rem;
}
.banner-info { background: #dbeafe; color: #1e40af; }
.banner-warning { background: #fef3c7; color: #92400e; }
.banner-success { background: #d1fae5; color: #065f46; }
.banner-danger { background: #fee2e2; color: #991b1b; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 1.25rem; }
.card-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); background: #fafafa; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .375rem;
    padding: .5rem 1.25rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all .2s;
    text-decoration: none;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); color: white; }

.btn-accent { background: var(--accent); color: var(--text); }
.btn-accent:hover { background: var(--accent-light); }

.btn-outline { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-sm { padding: .25rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 2rem; font-size: 1rem; }
.btn-block { width: 100%; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; font-size: .875rem; margin-bottom: .375rem; color: var(--text); }
.form-hint { font-size: .75rem; color: var(--text-light); margin-top: .25rem; }

.form-control {
    width: 100%;
    padding: .625rem .875rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: .9375rem;
    font-family: inherit;
    transition: border-color .2s;
    background: var(--bg-white);
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,94,31,.1);
}

select.form-control { appearance: auto; }
textarea.form-control { min-height: 100px; resize: vertical; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: .875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: .9rem;
    border-left: 4px solid;
}
.alert-success { background: #d1fae5; border-color: var(--success); color: #065f46; }
.alert-warning { background: #fef3c7; border-color: var(--warning); color: #92400e; }
.alert-danger { background: #fee2e2; border-color: var(--danger); color: #991b1b; }
.alert-info { background: #dbeafe; border-color: var(--info); color: #1e40af; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; }
table th, table td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--border); font-size: .875rem; }
table th { font-weight: 600; background: #f9fafb; position: sticky; top: 0; }
table tbody tr:hover { background: #f9fafb; }
table td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================
   PLAYER CARD
   ============================================================ */
.player-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-white);
    transition: all .2s;
    cursor: pointer;
}
.player-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }

.player-photo {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--bg);
}

.player-info { flex: 1; min-width: 0; }
.player-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-meta { font-size: .75rem; color: var(--text-light); display: flex; gap: .5rem; align-items: center; }

.player-price { font-weight: 700; color: var(--primary); white-space: nowrap; }
.player-points { font-weight: 700; font-size: .9rem; }

.pos-badge {
    display: inline-block;
    padding: .125rem .5rem;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 700;
    color: white;
    text-transform: uppercase;
}
.pos-gk { background: var(--gk); }
.pos-def { background: var(--def); }
.pos-mid { background: var(--mid); }
.pos-fwd { background: var(--fwd); }

/* ============================================================
   PITCH VIEW (Team Selection)
   ============================================================ */
.pitch {
    background: linear-gradient(180deg, #2d8a33 0%, #1a6e20 50%, #2d8a33 100%);
    border-radius: var(--radius-lg);
    padding: 1.5rem .5rem;
    position: relative;
    min-height: 500px;
}

.pitch-row {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 1rem;
}

.pitch-player {
    text-align: center;
    width: 70px;
    cursor: pointer;
    transition: transform .2s;
}
.pitch-player:hover { transform: scale(1.05); }

.pitch-player .shirt {
    width: 48px;
    height: 48px;
    margin: 0 auto .25rem;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .75rem;
    box-shadow: 0 2px 4px rgba(0,0,0,.2);
    border: 2px solid transparent;
}
.pitch-player.captain .shirt { border-color: var(--accent); }
.pitch-player.vice-captain .shirt { border-color: #c084fc; }

.pitch-player .pname {
    font-size: .65rem;
    color: white;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,.5);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
}

.pitch-player .ppts {
    font-size: .7rem;
    color: var(--accent);
    font-weight: 700;
}

.pitch-bench {
    background: rgba(0,0,0,.2);
    border-radius: var(--radius);
    padding: .75rem;
    margin-top: .5rem;
}

.bench-label {
    color: rgba(255,255,255,.7);
    font-size: .75rem;
    text-align: center;
    margin-bottom: .5rem;
    font-weight: 600;
}

/* ============================================================
   GRID
   ============================================================ */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .grid-2-mob { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   STATS / NUMBERS
   ============================================================ */
.stat-box {
    text-align: center;
    padding: 1rem;
}
.stat-value { font-size: 1.75rem; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-label { font-size: .75rem; color: var(--text-light); margin-top: .25rem; text-transform: uppercase; font-weight: 600; letter-spacing: .05em; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination ul {
    display: flex;
    gap: .25rem;
    list-style: none;
    justify-content: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}
.pagination li a {
    display: block;
    padding: .375rem .75rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-size: .875rem;
    color: var(--text);
}
.pagination li.active a,
.pagination li a:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    text-decoration: none;
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,.7);
    padding: 2rem 0;
    margin-top: 3rem;
    text-align: center;
    font-size: .8rem;
}
.site-footer a { color: var(--accent); }

/* ============================================================
   HERO (Landing)
   ============================================================ */
.hero {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    color: white;
    text-align: center;
    padding: 4rem 1rem;
}
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: .5rem; }
.hero p { font-size: 1.125rem; opacity: .9; max-width: 600px; margin: 0 auto 1.5rem; }

@media (max-width: 768px) {
    .hero { padding: 2.5rem 1rem; }
    .hero h1 { font-size: 1.75rem; }
}

/* ============================================================
   FIXTURE CARD
   ============================================================ */
.fixture-card {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: .875rem;
    border-bottom: 1px solid var(--border);
}
.fixture-card:last-child { border-bottom: none; }

.fixture-team {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex: 1;
    font-weight: 600;
    font-size: .875rem;
}
.fixture-team.home { justify-content: flex-end; text-align: right; }
.fixture-team.away { justify-content: flex-start; }
.fixture-team img { width: 24px; height: 24px; }

.fixture-score {
    min-width: 60px;
    text-align: center;
    font-weight: 800;
    font-size: 1.125rem;
    padding: .25rem .5rem;
    border-radius: var(--radius);
    background: var(--bg);
}
.fixture-score.live { background: var(--danger); color: white; animation: pulse 2s infinite; }

.fixture-time { font-size: .75rem; color: var(--text-light); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .7; } }

/* ============================================================
   LEAGUE TABLE
   ============================================================ */
.league-table th:first-child,
.league-table td:first-child { width: 40px; text-align: center; }

.rank-up { color: var(--success); }
.rank-down { color: var(--danger); }
.rank-same { color: var(--text-lighter); }

/* ============================================================
   TABS
   ============================================================ */
.tabs { display: flex; border-bottom: 2px solid var(--border); gap: 0; overflow-x: auto; }
.tab {
    padding: .75rem 1.25rem;
    font-weight: 600;
    font-size: .875rem;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    cursor: pointer;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}
.tab:hover, .tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    text-decoration: none;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 1rem;
    overflow-y: auto;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-md);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-light);
    padding: .25rem;
}
.modal-body { padding: 1.25rem; }
.modal-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }

/* ============================================================
   UTILITY
   ============================================================ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-light { color: var(--text-light); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.font-bold { font-weight: 700; }
.font-xl { font-size: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.p-0 { padding: 0; }
.p-2 { padding: 1rem; }
.d-flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.hidden { display: none; }

.badge {
    display: inline-block;
    padding: .125rem .5rem;
    border-radius: 99px;
    font-size: .7rem;
    font-weight: 700;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* Admin-specific */
.admin-sidebar {
    width: 220px;
    background: var(--primary-dark);
    min-height: 100vh;
    padding-top: 1rem;
}
.admin-sidebar a {
    display: block;
    padding: .625rem 1.25rem;
    color: rgba(255,255,255,.8);
    font-size: .875rem;
    font-weight: 500;
    transition: all .2s;
}
.admin-sidebar a:hover, .admin-sidebar a.active {
    background: rgba(255,255,255,.1);
    color: white;
    text-decoration: none;
}
.admin-layout { display: flex; }
.admin-main { flex: 1; padding: 1.5rem; min-width: 0; }

@media (max-width: 768px) {
    .admin-layout { flex-direction: column; }
    .admin-sidebar { width: 100%; min-height: auto; display: flex; overflow-x: auto; padding: 0; }
    .admin-sidebar a { white-space: nowrap; padding: .75rem 1rem; }
}

