/* ============================================================
   LaxHub — Main Stylesheet
   St. Pauli-inspired: warm brown header, clean white body
   ============================================================ */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    /* St. Pauli-inspired palette */
    --color-brown:      #7B3226;   /* primary brown */
    --color-brown-dk:   #5C2419;   /* darker brown */
    --color-brown-lt:   #9B4A38;   /* lighter brown */
    --color-amber:      #D4820A;   /* amber accent */
    --color-amber-lt:   #F0A500;   /* lighter amber */

    --color-primary:    var(--color-brown);
    --color-primary-dk: var(--color-brown-dk);
    --color-accent:     var(--color-amber);

    --color-bg:         #F7F4F2;   /* warm off-white */
    --color-surface:    #FFFFFF;
    --color-border:     #E2D9D5;
    --color-text:       #1C1009;
    --color-muted:      #7A6A62;
    --color-danger:     #DC2626;
    --color-success:    #16A34A;

    --radius:           8px;
    --shadow:           0 2px 12px rgba(123,50,38,.10);
    --shadow-md:        0 4px 20px rgba(123,50,38,.14);
    --transition:       .2s ease;
    --header-h:         64px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--color-brown); text-decoration: none; }
a:hover { color: var(--color-brown-lt); text-decoration: underline; }
img { max-width: 100%; height: auto; }

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.main-content {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* ---------- Header ---------- */
.site-header {
    background: linear-gradient(135deg, var(--color-brown-dk) 0%, var(--color-brown) 60%, var(--color-brown-lt) 100%);
    color: #fff;
    height: var(--header-h);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 3px 16px rgba(92,36,25,.35);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1rem;
}

.site-logo {
    font-size: 1.45rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: .5px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.site-logo::before { content: ''; }
.site-logo:hover { text-decoration: none; color: #fde8c8; }

.site-nav {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.site-nav a {
    color: rgba(255,255,255,.88);
    font-size: .9rem;
    font-weight: 500;
    text-decoration: none;
    padding: .3rem .65rem;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.site-nav a:hover { background: rgba(255,255,255,.18); color: #fff; text-decoration: none; }

.nav-user {
    color: rgba(255,255,255,.7);
    font-size: .82rem;
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .2rem .6rem;
    background: rgba(0,0,0,.18);
    border-radius: 20px;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: .25rem .5rem;
}

/* ---------- Role Badges ---------- */
.role-badge {
    font-size: .7rem;
    padding: .15rem .5rem;
    border-radius: 20px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
}
.role-admin              { background: #fef3c7; color: #92400e; }
.role-tournament_manager { background: #fce7dc; color: var(--color-brown-dk); }
.role-team_manager       { background: #dcfce7; color: #166534; }

/* ---------- Cards ---------- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: .75rem;
    border-bottom: 2px solid var(--color-border);
}

.card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-brown);
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* ---------- Grid ---------- */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem; }

/* ---------- Page Title ---------- */
.page-title {
    font-size: 1.7rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.15rem;
    border-radius: var(--radius);
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary  { background: var(--color-brown);  color: #fff; }
.btn-primary:hover { background: var(--color-brown-lt); filter: none; }
.btn-accent   { background: var(--color-amber); color: #fff; }
.btn-accent:hover { background: var(--color-amber-lt); filter: none; }
.btn-danger   { background: var(--color-danger); color: #fff; }
.btn-outline  { background: transparent; color: var(--color-brown); border: 1.5px solid var(--color-brown); }
.btn-outline:hover { background: var(--color-brown); color: #fff; filter: none; }
.btn-sm       { padding: .3rem .7rem; font-size: .82rem; }
.btn-ghost    { background: #fff; color: var(--color-text); border: 1px solid var(--color-border); }
.btn-ghost:hover { background: #f0e8e5; border-color: #c9b5af; filter: none; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1.1rem; }

label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    margin-bottom: .35rem;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: .6rem .85rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    font-size: .95rem;
    font-family: inherit;
    background: #fff;
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-brown);
    box-shadow: 0 0 0 3px rgba(123,50,38,.12);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-actions {
    display: flex;
    gap: .75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

thead th {
    background: #F0E8E5;
    padding: .7rem 1rem;
    text-align: left;
    font-weight: 700;
    font-size: .78rem;
    color: var(--color-brown-dk);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 2px solid #D9C5BF;
    white-space: nowrap;
}

tbody td {
    padding: .7rem 1rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    color: var(--color-text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FDF6F4; }

.td-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- Alerts ---------- */
.alert {
    padding: .85rem 1.1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: .9rem;
    font-weight: 500;
    border-left: 4px solid;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: var(--color-success); }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: var(--color-danger); }
.alert-info    { background: #fef8ec; color: #92400e; border-color: var(--color-amber); }

/* ---------- Team Logo ---------- */
.team-logo {
    width: 48px; height: 48px;
    object-fit: contain;
    border-radius: 6px;
    border: 1px solid var(--color-border);
}
.team-logo-lg {
    width: 80px; height: 80px;
    object-fit: contain;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}
.logo-placeholder {
    width: 48px; height: 48px;
    background: #f5ede9;
    border: 1px dashed #c9b5af;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    color: var(--color-muted); font-size: .7rem;
}

/* ---------- Season & Tournament tiles ---------- */
.season-section { margin-bottom: 2.5rem; }
.season-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-brown);
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: .35rem 0 .35rem .8rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--color-amber);
    background: linear-gradient(90deg, #fef6ee 0%, transparent 100%);
    border-radius: 0 4px 4px 0;
}

.tournament-tile {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
    gap: .5rem;
    position: relative;
    overflow: hidden;
    border-top: 3px solid var(--color-brown);
}
.tournament-tile:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.tournament-tile h3 { font-size: 1rem; font-weight: 700; color: var(--color-text); }
.tournament-tile .meta { font-size: .82rem; color: var(--color-muted); }

/* ---------- Player Jersey (shirt shape) ---------- */
.jersey {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-brown);
    color: #fff;
    font-weight: 900;
    font-size: .78rem;
    width: 34px;
    height: 34px;
    /* Jersey silhouette: collar V-neck + sleeves + body */
    clip-path: polygon(
        0% 0%, 0% 24%, 18% 31%, 18% 100%,
        82% 100%, 82% 31%, 100% 24%, 100% 0%,
        74% 0%, 50% 9%, 26% 0%
    );
    padding-top: 3px; /* push text into body, away from collar cutout */
}

/* ---------- Dashboard ---------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 4px solid var(--color-brown);
    border-radius: var(--radius);
    padding: 1.5rem 1.25rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .stat-num { font-size: 2.5rem; font-weight: 900; color: var(--color-brown); line-height: 1; margin-bottom: .25rem; }
.stat-card .stat-label { font-size: .8rem; color: var(--color-muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- Login Page ---------- */
.login-wrap {
    min-height: calc(100vh - var(--header-h) - 80px);
    display: flex; align-items: center; justify-content: center;
}
.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 4px solid var(--color-brown);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%; max-width: 400px;
    box-shadow: var(--shadow-md);
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 1.5rem; text-align: center; font-weight: 800; color: var(--color-brown); }

/* ---------- Footer ---------- */
.site-footer {
    background: var(--color-brown-dk);
    color: rgba(255,255,255,.5);
    padding: 1.25rem 0;
    text-align: center;
    font-size: .82rem;
    margin-top: auto;
    border-top: 3px solid var(--color-amber);
}

/* ---------- Match header ---------- */
.match-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 1rem;
    padding: .75rem 0 1.25rem;
}

.match-team {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    min-width: 0; /* allow shrinking inside grid */
}

.match-team-name {
    font-size: 1.1rem;
    font-weight: 800;
    text-align: center;
    color: var(--color-text);
    word-break: break-word;
    overflow-wrap: anywhere;
    text-decoration: none;
}
.match-team-name:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .match-team-name { font-size: .85rem; }
    .live-score      { font-size: 2.4rem; }
    .live-score-sep  { font-size: 1.8rem; }
}

.match-badge {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .06em;
    padding: .18rem .55rem;
    border-radius: 20px;
    background: var(--color-brown);
    color: #fff;
    text-transform: uppercase;
}
.match-badge.away { background: var(--color-muted); }

.match-vs {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--color-muted);
}

.match-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    font-size: .85rem;
    color: var(--color-muted);
    border-top: 1px solid var(--color-border);
    padding-top: .85rem;
}

/* ---------- Section heading ---------- */
.section-heading {
    font-size: .8rem;
    font-weight: 800;
    color: var(--color-brown);
    text-transform: uppercase;
    letter-spacing: .1em;
    margin-bottom: .75rem;
    padding-left: .75rem;
    border-left: 3px solid var(--color-amber);
}

/* ---------- Stats table ---------- */
.stats-table thead th { text-align: center; white-space: nowrap; }
.stats-table tbody td { text-align: center; }
.stats-table .th-player,
.stats-table .th-team,
.stats-table tbody td.td-player,
.stats-table tbody td.td-team { text-align: left; }
.stats-table .th-rank,
.stats-table .td-rank { width: 36px; color: var(--color-muted); font-size: .82rem; }

.sort-link {
    color: inherit; text-decoration: none;
    display: inline-flex; align-items: center; gap: .2rem;
    white-space: nowrap;
}
.sort-link:hover { color: var(--color-brown); text-decoration: none; }
.sort-icon { font-size: .75rem; color: var(--color-muted); }
.sort-icon.active { color: var(--color-amber); }
.col-active { background: #fef6ee; }

.player-cell { display: inline-flex; align-items: center; gap: .4rem; }

/* ---------- Live match badges ---------- */
.live-badge-view {
    display: inline-flex; align-items: center; gap: .35rem;
    background: #fef2f2; color: #991b1b;
    border: 1px solid #fecaca;
    font-size: .8rem; font-weight: 700;
    padding: .25rem .7rem; border-radius: 20px;
    letter-spacing: .05em;
}
.live-dot-view {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--color-danger); animation: livePulse 1s infinite;
}
.live-dot-sm {
    display: inline-block; width: 8px; height: 8px;
    border-radius: 50%; background: var(--color-danger);
    animation: livePulse 1s infinite; vertical-align: middle;
    margin-right: .25rem;
}
@keyframes livePulse { 0%,100%{opacity:1} 50%{opacity:.2} }

.final-badge {
    display: inline-block;
    background: #f0fdf4; color: #166534;
    border: 1px solid #bbf7d0;
    font-size: .75rem; font-weight: 700;
    padding: .2rem .7rem; border-radius: 20px;
    letter-spacing: .06em;
}

/* Live score display in match/view */
.live-score-display { display: flex; align-items: center; gap: .6rem; }
.live-score {
    font-size: 3.5rem; font-weight: 900;
    color: var(--color-brown); line-height: 1;
    font-variant-numeric: tabular-nums;
}
.live-score-sep {
    font-size: 2.5rem; font-weight: 900;
    color: var(--color-muted); line-height: 1;
}

/* Inline score in tournament schedule table */
.inline-score {
    font-weight: 800; font-size: .95rem;
    color: var(--color-brown);
    font-variant-numeric: tabular-nums;
}
.inline-score.finished { color: var(--color-muted); }

/* ---------- Utilities ---------- */
.text-muted  { color: var(--color-muted); font-size: .88rem; }
.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }

/* ---------- Responsive ---------- */
/* Schedule team name — hidden on mobile */
.schedule-team-name { display:inline; margin-left:.35rem; }
.sched-hide-mobile  { display:inline; }
.sched-logo-link    { display:inline-flex; align-items:center; }
.hide-mobile        { display:table-cell; }
.sched-initials {
    display:inline-flex; align-items:center; justify-content:center;
    width:26px; height:26px; border-radius:4px;
    background:var(--color-border); color:var(--color-muted);
    font-size:.65rem; font-weight:700; text-transform:uppercase;
    flex-shrink:0;
}

@media (max-width: 768px) {
    .schedule-team-name { display:none; }
    /* When the team is not yet decided there is no logo to show, so keep the
       placeholder text (e.g. "L633", "1° NORD", "TBD") visible on mobile. */
    .schedule-team-name.sched-placeholder { display:inline; }
    .sched-hide-mobile  { display:none; }
    .hide-mobile        { display:none; }

    .nav-toggle { display: block; }

    .site-nav {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        position: absolute;
        top: var(--header-h);
        left: 0; right: 0;
        background: var(--color-brown-dk);
        padding: 1rem;
        gap: .75rem;
        z-index: 99;
        box-shadow: 0 8px 20px rgba(0,0,0,.25);
    }
    .site-nav.open { display: flex; }
    .site-header { position: relative; }

    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .form-row { grid-template-columns: 1fr; }

    .page-title { font-size: 1.3rem; }

    table { font-size: .83rem; }
    thead th, tbody td { padding: .5rem .4rem; }
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}

@media (max-width: 480px) {
    .main-content { padding: 1rem .75rem; }
    .card { padding: 1rem; }
    .login-card { padding: 1.75rem 1.25rem; }
}

@media (max-width: 768px) { .hide-mobile { display: none !important; } }
