/* =============================================
   SOUTHEND UNITED HISTORY - STYLESHEET
   Royal Blue & White | Classic Football Archive
   ============================================= */

:root {
    --royal-blue: #003087;
    --blue-mid: #004abf;
    --blue-light: #1a5ccc;
    --blue-pale: #e8eef8;
    --white: #ffffff;
    --off-white: #f4f6fb;
    --text-dark: #111827;
    --text-mid: #374151;
    --text-light: #6b7280;
    --border: #d1d9ee;
    --gold-accent: #c8a84b;
    --win: #1a7a3c;
    --draw: #b07a00;
    --loss: #9b1c1c;
    --shadow: 0 4px 24px rgba(0, 48, 135, 0.10);
    --shadow-lg: 0 8px 40px rgba(0, 48, 135, 0.18);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Source Sans 3', sans-serif;
    background: var(--off-white);
    color: var(--text-dark);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- HEADER ---- */
.site-header {
    background: var(--royal-blue);
    background-image: linear-gradient(135deg, #001f5c 0%, #003087 50%, #004abf 100%);
    color: var(--white);
    padding: 2rem 1.5rem;
    border-bottom: 4px solid var(--gold-accent);
    box-shadow: var(--shadow-lg);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header-crest { font-size: 3rem; filter: drop-shadow(0 2px 8px rgba(0,0,0,0.3)); }

.site-title {
    font-family: 'Playfair Display', serif;
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 900;
    letter-spacing: -0.01em;
    line-height: 1.1;
    color: var(--white);
}

.site-subtitle {
    font-size: 0.95rem;
    color: rgba(255,255,255,0.7);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-top: 0.3rem;
    font-weight: 300;
}

/* ---- MAIN ---- */
.main-content {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    flex: 1;
    width: 100%;
}

/* ---- PANEL TITLES ---- */
.panel-title {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--royal-blue);
    margin-bottom: 1.2rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gold-accent);
    display: inline-block;
}

/* ---- FILTERS PANEL ---- */
.filters-panel {
    background: var(--white);
    border-radius: 12px;
    padding: 1.8rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filter-group { display: flex; flex-direction: column; gap: 0.4rem; }

.filter-group label {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light);
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 0.55rem 0.8rem;
    border: 1.5px solid var(--border);
    border-radius: 7px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 0.95rem;
    color: var(--text-dark);
    background: var(--white);
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23003087' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2.2rem;
}

.filter-group input[type="text"] { background-image: none; padding-right: 0.8rem; }

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--blue-light);
    box-shadow: 0 0 0 3px rgba(26, 92, 204, 0.15);
}

.filter-actions { display: flex; gap: 1rem; flex-wrap: wrap; }

.btn-primary {
    background: var(--royal-blue);
    color: var(--white);
    border: none;
    padding: 0.65rem 2rem;
    border-radius: 7px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.04em;
}

.btn-primary:hover { background: var(--blue-light); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
    background: transparent;
    color: var(--royal-blue);
    border: 1.5px solid var(--royal-blue);
    padding: 0.65rem 1.5rem;
    border-radius: 7px;
    font-family: 'Source Sans 3', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-secondary:hover { background: var(--blue-pale); }

/* ---- RESULTS PANEL ---- */
.results-panel {
    background: var(--white);
    border-radius: 12px;
    padding: 1.8rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.results-header { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.2rem; }
.match-count { font-size: 0.9rem; color: var(--text-light); font-weight: 400; }

.table-wrapper { overflow-x: visible; border-radius: 8px; border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: var(--royal-blue); color: var(--white); }

thead th {
    padding: 0.75rem 0.9rem;
    text-align: left;
    font-weight: 600;
    letter-spacing: 0.05em;
    font-size: 0.8rem;
    text-transform: uppercase;
    white-space: nowrap;
}

tbody tr { border-bottom: 1px solid var(--border); transition: background 0.15s; cursor: pointer; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--blue-pale); }
tbody td { padding: 0.65rem 0.9rem; color: var(--text-mid); white-space: nowrap; }
tbody tr:nth-child(even) { background: var(--off-white); }
tbody tr:nth-child(even):hover { background: var(--blue-pale); }

.placeholder-row td {
    text-align: center;
    color: var(--text-light);
    padding: 3rem;
    font-style: italic;
    cursor: default;
}

/* Result badges */
.badge { display: inline-block; padding: 0.2rem 0.6rem; border-radius: 4px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.05em; }
.badge-W { background: #d1fae5; color: var(--win); }
.badge-D { background: #fef3c7; color: var(--draw); }
.badge-L { background: #fee2e2; color: var(--loss); }
.badge-other { background: var(--blue-pale); color: var(--royal-blue); }

/* ---- SORTABLE COLUMNS ---- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background: var(--blue-mid); }
th.sort-asc .sort-icon::after  { content: ' ▲'; }
th.sort-desc .sort-icon::after { content: ' ▼'; }
th.sort-asc .sort-icon, th.sort-desc .sort-icon { opacity: 1; }
.sort-icon { opacity: 0.4; font-size: 0.75rem; }

/* ---- MODAL OVERLAY ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 20, 70, 0.65);
    backdrop-filter: blur(3px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
}

/* =============================================
   VINTAGE PROGRAMME MODAL
   ============================================= */

/* Override modal box for vintage look */
.modal-box {
    background: #f5f0e8;
    border: 3px solid #1a1a1a;
    border-radius: 0;
    max-width: 1100px;
    font-family: 'Times New Roman', Times, Georgia, serif;
}

#modal-content {
    padding: 0;
}

/* Close button vintage style */
.modal-close {
    background: #1a1a1a;
    border-radius: 0;
    font-weight: bold;
    top: 0.6rem;
    right: 0.6rem;
}

/* Wrapper */
.vp-wrap {
    background: #f5f0e8;
    color: #1a1a1a;
}

/* ---- MASTHEAD ---- */
.vp-masthead {
    background: #fff;
    border-bottom: 4px double #1a1a1a;
    padding: 1rem 1.5rem 0.8rem;
    text-align: center;
}

.vp-masthead-title {
    font-family: 'Playfair Display', 'Times New Roman', serif;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #1a1a1a;
    line-height: 1;
}

.vp-masthead-rule {
    border: none;
    border-top: 2px solid #1a1a1a;
    margin: 0.5rem auto;
    width: 100%;
}

.vp-masthead-match {
    font-size: clamp(0.95rem, 2vw, 1.25rem);
    font-weight: bold;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #1a1a1a;
}

.vp-vs {
    font-style: italic;
    font-weight: normal;
    margin: 0 0.4rem;
}

.vp-masthead-score {
    font-family: 'Playfair Display', serif;
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 900;
    color: #003087;
    letter-spacing: 0.15em;
    margin: 0.2rem 0;
    line-height: 1.1;
}

.vp-masthead-info {
    font-size: 0.8rem;
    color: #444;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
    font-style: italic;
}

/* ---- THREE COLUMNS ---- */
.vp-columns {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1.4fr 1.2fr;
    border-top: 2px solid #1a1a1a;
    min-height: 300px;
}

.vp-col {
    padding: 0.8rem 0.9rem;
    border-right: 1px solid #1a1a1a;
}

.vp-col:last-child { border-right: none; }

.vp-col-head {
    font-family: 'Playfair Display', serif;
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #1a1a1a;
    border-bottom: 2px solid #1a1a1a;
    padding-bottom: 0.35rem;
    margin-bottom: 0.6rem;
    font-style: italic;
}

/* Goalscorers */
.vp-scorer {
    font-size: 0.88rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid #ccc;
    color: #1a1a1a;
    line-height: 1.4;
}
.vp-scorer:last-child { border-bottom: none; }
.vp-empty { color: #888; font-style: italic; font-size: 0.85rem; }

/* Players */
.vp-player {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.28rem 0;
    border-bottom: 1px solid #ccc;
    font-size: 0.88rem;
}
.vp-player:last-child { border-bottom: none; }

.vp-num {
    font-weight: bold;
    min-width: 1.3rem;
    color: #003087;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.vp-name { color: #1a1a1a; }

/* Details */
.vp-detail {
    padding: 0.3rem 0;
    border-bottom: 1px solid #ccc;
    font-size: 0.85rem;
    line-height: 1.4;
}
.vp-detail:last-child { border-bottom: none; }

.vp-detail-label {
    font-weight: bold;
    font-style: italic;
    color: #333;
    margin-right: 0.3rem;
    font-size: 0.8rem;
}
.vp-detail-value { color: #1a1a1a; }

/* Substitutes in details column */
.vp-subs {
    margin-top: 0.8rem;
    padding-top: 0.6rem;
    border-top: 2px solid #1a1a1a;
}
.vp-subs-heading {
    font-family: 'Playfair Display', serif;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-style: italic;
    margin-bottom: 0.4rem;
    color: #1a1a1a;
}

/* Responsive */
@media (max-width: 600px) {
    .vp-columns { grid-template-columns: 1fr; }
    .vp-col { border-right: none; border-bottom: 1px solid #1a1a1a; }
    .vp-col:last-child { border-bottom: none; }
}

/* Discipline colours in match modal */
.vp-booked .vp-detail-label,
.vp-booked .vp-detail-value { color: #c47800; font-weight: bold; }

.vp-sentoff .vp-detail-label,
.vp-sentoff .vp-detail-value { color: #cc0000; font-weight: bold; }

/* Discipline blocks in column 4 */
.vp-discipline-block {
    margin-top: 0.8rem;
    padding: 0.5rem 0.6rem;
    border-radius: 4px;
    border: 1px solid;
}

.vp-discipline-head {
    font-size: 0.75rem;
    font-weight: bold;
    font-style: italic;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.3rem;
}

.vp-discipline-names {
    font-size: 0.88rem;
    line-height: 1.5;
}

.vp-booked {
    background: #fff8e6;
    border-color: #c47800 !important;
}
.vp-booked .vp-discipline-head { color: #c47800; }
.vp-booked .vp-discipline-names { color: #7a4a00; }

.vp-sentoff {
    background: #fff0f0;
    border-color: #cc0000 !important;
}
.vp-sentoff .vp-discipline-head { color: #cc0000; }
.vp-sentoff .vp-discipline-names { color: #7a0000; }

/* 4-col responsive */
@media (max-width: 800px) {
    .vp-columns { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 500px) {
    .vp-columns { grid-template-columns: 1fr; }
}

/* =============================================
   RECORDS PAGE
   ============================================= */
.records-loading {
    text-align: center;
    padding: 4rem;
    color: var(--text-light);
    font-style: italic;
    font-size: 1rem;
}

.records-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.record-card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.record-card-header {
    background: var(--royal-blue);
    color: var(--white);
    padding: 0.75rem 1.2rem;
    font-family: 'Playfair Display', serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.record-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
    font-size: 0.88rem;
    transition: background 0.15s;
    min-width: 0;
}

.record-row:last-child { border-bottom: none; }

.record-clickable { cursor: pointer; }
.record-clickable:hover { background: var(--blue-pale); }

.record-row-left {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.record-row-rank {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--white);
    background: var(--royal-blue);
    border-radius: 50%;
    width: 1.4rem;
    height: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.record-row-main {
    font-weight: 600;
    color: var(--text-dark);
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.record-row-sub {
    font-size: 0.78rem;
    color: var(--text-light);
    margin-top: 0.2rem;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

.record-row-value {
    font-family: 'Playfair Display', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--royal-blue);
    white-space: nowrap;
    flex-shrink: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--royal-blue);
    font-weight: 600;
    text-decoration: none;
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    transition: color 0.2s;
}
.back-link:hover { color: var(--blue-light); }

@media (max-width: 500px) {
    .records-grid { grid-template-columns: 1fr; }
}

/* Modal scroll fix */
.modal-box {
    max-height: 90vh !important;
    overflow-y: auto !important;
}

/* ---- MERGED MATCH MODAL ---- */
.merged-block {
    margin-bottom: 1rem;
}

.merged-block-title {
    font-family: 'Playfair Display', serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--royal-blue);
    background: var(--blue-pale);
    padding: 0.3rem 0.6rem;
    border-left: 3px solid var(--royal-blue);
    margin-bottom: 0.6rem;
    font-style: italic;
}

.merged-cols {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 1rem;
}

.merged-col { min-width: 0; }

.merged-divider {
    border-top: 2px solid #1a1a1a;
    margin: 1rem 0;
}


/* ---- STATISTICS SEARCH PAGE - COLUMN WIDTHS ---- */
#results-table th[data-col="Date"],
#results-table td:nth-child(1) { width: 95px; min-width: 95px; }

#results-table th[data-col="Season"],
#results-table td:nth-child(2) { width: 75px; min-width: 75px; }

#results-table th[data-col="Competition"],
#results-table td:nth-child(3) { white-space: normal; word-wrap: break-word; min-width: 140px; max-width: 220px; vertical-align: top; }

#results-table th[data-col="Opponents"],
#results-table td:nth-child(4) { min-width: 140px; }

#results-table th[data-col="Venue"],
#results-table td:nth-child(5) { width: 90px; min-width: 90px; }

#results-table th[data-col="Score"],
#results-table td:nth-child(6) { width: 65px; min-width: 65px; text-align: center; }

#results-table th[data-col="HT"],
#results-table td:nth-child(7) { width: 60px; min-width: 60px; text-align: center; }

#results-table th[data-col="WDL"],
#results-table td:nth-child(8) { width: 70px; min-width: 70px; text-align: center; }
