/* Hampton Boules League — Piste Booking System */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --green: #0f3d28;
    --green-mid: #1a5c3a;
    --green-light: #EAF3DE;
    --green-bright: #4ade80;
    --amber: #FFC000;
    --red: #C00000;
    --blue: #185FA5;
    --border: rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
}

body { font-family: Georgia, serif; color: #1a1a1a; background: #f5f5f0; line-height: 1.5; font-size: 15px; }

/* AUTH */
.auth-page { background: var(--green); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-wrap { width: 100%; max-width: 380px; }
.auth-logo { text-align: center; margin-bottom: 1.5rem; color: #fff; }
.auth-gem { font-size: 2.5rem; color: var(--green-bright); display: block; margin-bottom: .5rem; }
.auth-logo h1 { font-size: 1.4rem; font-weight: normal; }
.auth-logo p { color: rgba(255,255,255,.65); font-size: .9rem; margin-top: .25rem; }
.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 1.75rem; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.auth-card h2 { font-size: 1.1rem; font-weight: normal; margin-bottom: 1.25rem; }
.auth-note { font-size: .8rem; color: #888; margin-top: .875rem; line-height: 1.6; }

/* HEADER */
.site-header { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,.2); }
.header-inner { max-width: 1200px; margin: 0 auto; padding: .65rem 1.25rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.header-brand { display: flex; align-items: center; gap: .5rem; font-size: .95rem; }
.header-gem { color: var(--green-bright); }
.header-nav { display: flex; gap: 4px; flex: 1; }

/* TABS — using spans styled as tabs, not buttons, to avoid browser override */
.nav-tab {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 6px;
    border: 2px solid rgba(255,255,255,.35);
    color: rgba(255,255,255,.85);
    font-size: .8rem;
    font-family: Georgia, serif;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all .15s;
    user-select: none;
}
.nav-tab:hover { border-color: rgba(255,255,255,.7); color: #fff; }
.nav-tab.active {
    background: var(--green-bright) !important;
    border-color: var(--green-bright) !important;
    color: var(--green) !important;
    font-weight: 700 !important;
}

.header-user { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.22); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 600; color: #fff; border: 1.5px solid rgba(255,255,255,.4); }
.user-name { font-size: .8rem; color: #fff; font-weight: 500; }
.user-role { font-size: .7rem; color: rgba(255,255,255,.65); }
.sign-out-btn { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.35); color: #fff; padding: 3px 10px; border-radius: 4px; font-size: .75rem; cursor: pointer; font-family: Georgia, serif; text-decoration: none; }
.sign-out-btn:hover { background: rgba(255,255,255,.25); }

/* MAIN */
.main-content { max-width: 1200px; margin: 0 auto; padding: 1.25rem; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* FORMS */
.field { margin-bottom: .875rem; }
.field label { display: block; font-size: .8rem; color: #666; margin-bottom: 3px; font-family: Georgia, serif; }
.field input, .field select, .field textarea {
    width: 100%; padding: 7px 9px; border: 1px solid #ccc;
    border-radius: var(--radius); font-size: .85rem; font-family: Georgia, serif;
    background: #fff; color: #1a1a1a; transition: border-color .15s;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--green); }
.field .hint { font-size: .75rem; color: #999; font-family: Georgia, serif; }

/* BUTTONS */
.btn { padding: 7px 14px; border-radius: var(--radius); border: 1px solid #ccc; background: #fff; color: #1a1a1a; font-size: .82rem; cursor: pointer; font-family: Georgia, serif; transition: all .15s; text-decoration: none; display: inline-block; }
.btn:hover { background: #f5f5f0; }
.btn-primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn-primary:hover { background: var(--green-mid); }
.btn-danger { background: #FCEBEB; color: var(--red); border-color: transparent; }
.btn-danger:hover { background: #f8d0d0; }
.btn-add { background: var(--green-light); color: #0f3d28; border-color: #3B6D11; }
.btn-full { width: 100%; text-align: center; }
.btn-sm { padding: 3px 9px; font-size: .75rem; }

/* ALERTS */
.alert { padding: 9px 12px; border-radius: var(--radius); font-size: .82rem; margin-bottom: .875rem; }
.alert-error { background: #FCEBEB; color: var(--red); border: 1px solid #f5c0c0; }

/* CARDS */
.card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.125rem; margin-bottom: .875rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .875rem; flex-wrap: wrap; gap: .5rem; }
.card-header h2 { font-size: 1rem; font-weight: normal; }
.muted { color: #888; font-size: .85rem; }

/* LEGEND */
.legend-bar { display: flex; gap: .875rem; flex-wrap: wrap; margin-bottom: .875rem; font-size: .75rem; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); flex-shrink: 0; }

/* CALENDAR */
.cal-nav { display: flex; align-items: center; gap: .75rem; margin-bottom: .875rem; }
.cal-nav h2 { flex: 1; text-align: center; font-size: .95rem; font-weight: normal; }
.month-indicator { font-size: .85rem; color: var(--green); font-weight: 600; padding: 2px 10px; background: var(--green-light); border-radius: 20px; }

.cal-outer { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: .875rem; background: #fff; }
.cal-topbar { display: flex; align-items: center; justify-content: space-between; padding: .4rem .75rem; background: #f5f5f0; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: .5rem; }
.cal-topbar-l { font-size: .85rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.cal-topbar-r { font-size: .75rem; color: #888; }
.cal-body { display: flex; align-items: stretch; }
.cal-arrow { width: 28px; flex-shrink: 0; background: #f5f5f0; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 18px; color: #888; user-select: none; }
.cal-arrow:hover { background: #e8e8e4; color: #1a1a1a; }
.cal-arrow-l { border-right: 1px solid var(--border); }
.cal-arrow-r { border-left: 1px solid var(--border); }
.cal-labels { flex-shrink: 0; border-right: 1px solid var(--border); }
.cl-month { height: 18px; background: #f5f5f0; border-bottom: 1px solid var(--border); }
.cl-row { height: 28px; display: flex; align-items: center; padding: 0 8px; font-size: .7rem; font-weight: 500; color: #888; border-bottom: 1px solid var(--border); background: #f5f5f0; white-space: nowrap; min-width: 60px; }
.cl-row:last-child { border-bottom: none; }
.cal-scroll { overflow: hidden; flex: 1; }
.cal-inner { display: flex; flex-direction: column; width: max-content; }
.months-row { display: flex; height: 18px; border-bottom: 1px solid var(--border); }
.mblock { display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 500; color: #888; background: #f5f5f0; border-right: 1px solid var(--border); }
.date-rows { display: flex; flex-direction: column; }
.date-row { display: flex; height: 28px; }
.cc { width: 26px; min-width: 26px; height: 28px; display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 500; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); flex-shrink: 0; cursor: pointer; user-select: none; transition: box-shadow .08s; }
.date-row:last-child .cc { border-bottom: none; }
.cc:last-child { border-right: none; }
.cc-free { background: #EAF3DE; color: #27500A; }
.cc-amber { background: #FAEEDA; color: #633806; }
.cc-red { background: #FCEBEB; color: #791F1F; }
.cc-grey { background: #f5f5f0; color: #ccc; cursor: default; }
.cc-today { box-shadow: inset 0 0 0 2px var(--green-bright); }
.cc-sel { box-shadow: inset 0 0 0 2.5px #1D9E75; z-index: 2; }
.cc-pending { box-shadow: inset 0 0 0 2px #BA7517; z-index: 2; }
/* Category coloured cells — set via inline style from DB */
.cc-cat { color: #000; }

/* PISTE MAP */
.piste-section { border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; background: #fff; }
.piste-hdr { display: flex; align-items: center; justify-content: space-between; padding: .4rem .875rem; background: #f5f5f0; border-bottom: 1px solid var(--border); }
.piste-hdr-l { font-size: .85rem; font-weight: 500; }
.piste-hdr-r { font-size: .75rem; color: #888; }
.piste-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.piste-map { display: flex; gap: 6px; padding: .75rem; align-items: stretch; height: 240px; min-width: 700px; }
.map-left { display: flex; flex-direction: column; gap: 4px; width: 220px; flex-shrink: 0; }
.ph-pair { flex: 1; border: 1.5px solid #ccc; border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: border-color .12s, box-shadow .12s; }
.ph-slot { flex: 1; padding: 4px 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; border-bottom: 1px solid rgba(0,0,0,.07); text-align: center; overflow: hidden; }
.ph-slot:last-child { border-bottom: none; }
.ph-num { font-size: .65rem; font-weight: 500; opacity: .6; margin-bottom: 2px; }
.ph-team { font-size: .7rem; font-weight: 500; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.map-right { display: flex; gap: 6px; flex: 1; align-self: stretch; }
.pv-pair { flex: 1; border: 1.5px solid #ccc; border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: row; transition: border-color .12s, box-shadow .12s; }
.pv-slot { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-right: 1px solid rgba(0,0,0,.07); overflow: hidden; position: relative; }
.pv-slot:last-child { border-right: none; }
.pv-num { font-size: .65rem; font-weight: 500; opacity: .6; position: absolute; top: 5px; left: 0; right: 0; text-align: center; }
.pv-body { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; overflow: hidden; position: relative; }
.pv-inner { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-90deg); width: 190px; display: flex; flex-direction: row; align-items: center; justify-content: center; gap: 4px; }
.pv-tbox { font-size: .6rem; font-weight: 500; line-height: 1.25; text-align: center; width: 75px; flex-shrink: 0; word-break: break-word; white-space: normal; }
.pv-v { font-size: .6rem; font-weight: 600; opacity: .6; flex-shrink: 0; }
.s-free { background: #EAF3DE; } .s-free .ph-num, .s-free .ph-team, .s-free .pv-num, .s-free .pv-team { color: #27500A; }
.s-bkd { background: #FCEBEB; } .s-bkd .ph-num, .s-bkd .ph-team, .s-bkd .pv-num, .s-bkd .pv-team { color: #791F1F; }
.s-amb { background: #FAEEDA; } .s-amb .ph-num, .s-amb .ph-team, .s-amb .pv-num, .s-amb .pv-team { color: #633806; }
.s-mine { background: #d4ecbc; } .s-mine .ph-num, .s-mine .ph-team, .s-mine .pv-num, .s-mine .pv-team { color: #0f3d28; }
.pair-hi { border-color: #1D9E75 !important; box-shadow: 0 0 0 2px #1D9E75 !important; }
.pair-nodrop { opacity: .3; pointer-events: none; }
.draggable { cursor: grab; }
.dragging-active { cursor: grabbing !important; }

/* GHOST */
.ghost { position: fixed; pointer-events: none; z-index: 9999; background: var(--green); color: #fff; padding: 6px 14px; border-radius: var(--radius); font-size: .82rem; font-weight: 500; white-space: nowrap; box-shadow: 0 4px 16px rgba(0,0,0,.35); transform: translate(-50%,-120%); display: none; }
.ghost.on { display: block; }
.ghost-sub { font-size: .65rem; color: rgba(255,255,255,.7); margin-top: 2px; }

/* HINT BAR */
.hint-bar { background: var(--green-light); border: 1px solid #3B6D11; border-radius: var(--radius); padding: .4rem .875rem; margin-bottom: .6rem; font-size: .82rem; color: #27500A; display: none; align-items: center; gap: .75rem; flex-wrap: wrap; }
.hint-bar.on { display: flex; }

/* FIXTURES */
.fix-list { display: flex; flex-direction: column; gap: 6px; }
.fix-item { display: flex; align-items: center; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); gap: 8px; background: #fff; }
.fi-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.fi-info { flex: 1; }
.fi-name { font-size: .88rem; font-weight: 500; }
.fi-meta { font-size: .75rem; color: #888; margin-top: 2px; }
.fi-badge { font-size: .7rem; padding: 2px 8px; border-radius: 20px; font-weight: 500; }
.fi-sched { background: #E6F1FB; color: #0C447C; }
.fi-moved { background: #EAF3DE; color: #27500A; }

/* TEAM TABLE */
.team-table { width: 100%; border-collapse: collapse; }
.team-table th { font-size: .75rem; font-weight: 500; color: #888; padding: 4px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.team-table th:first-child { text-align: left; }
.team-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.team-table tr:last-child td { border-bottom: none; }
.team-table td:not(:first-child) { text-align: center; }
.player-name-inp { font-size: .85rem; color: #1a1a1a; background: transparent; border: none; border-bottom: 1px dashed #ccc; width: 165px; font-family: Georgia, serif; padding: 1px 2px; outline: none; }
.player-name-inp:focus { border-bottom-color: var(--green); }
.rm-btn { width: 18px; height: 18px; border-radius: 50%; background: #f5f5f0; border: 1px solid #ccc; color: #999; font-size: .75rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rm-btn:hover { background: #FCEBEB; color: var(--red); border-color: var(--red); }
.achip { padding: 3px 8px; border-radius: 20px; font-size: .72rem; cursor: pointer; border: 1px solid transparent; font-family: Georgia, serif; font-weight: 500; min-width: 54px; text-align: center; }
.ayes { background: #EAF3DE; color: #27500A; }
.ano { background: #FCEBEB; color: #791F1F; }
.aunk { background: #f5f5f0; color: #888; border-color: #ccc; }
.add-row { display: flex; align-items: center; gap: 8px; padding: .75rem 0 .25rem; }

/* ADMIN */
.metrics-row { display: grid; grid-template-columns: repeat(4,1fr); gap: .75rem; margin-bottom: .875rem; }
.metric-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius-lg); padding: .875rem; text-align: center; }
.metric-val { font-size: 1.6rem; font-weight: 500; }
.metric-label { font-size: .75rem; color: #888; margin-top: 3px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: .875rem; }
.notif-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.notif-row:last-child { border-bottom: none; }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; margin-top: 4px; }
.notif-msg { flex: 1; font-size: .8rem; line-height: 1.4; }
.notif-time { font-size: .7rem; color: #888; white-space: nowrap; }
.captain-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.captain-row:last-child { border-bottom: none; }
.captain-av { width: 30px; height: 30px; border-radius: 50%; background: var(--green-light); display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 500; color: var(--green); flex-shrink: 0; }
.captain-info { flex: 1; }
.captain-name { font-size: .85rem; font-weight: 500; }
.captain-meta { font-size: .72rem; color: #888; }

/* TOAST */
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--green); color: #fff; padding: .5rem 1.25rem; border-radius: var(--radius-lg); font-size: .8rem; z-index: 9999; opacity: 0; transition: opacity .3s; pointer-events: none; white-space: nowrap; }
.toast.show { opacity: 1; }

/* COLOUR LEGEND SWATCHES */
.swatch-div1 { background: #FFFF00; }
.swatch-div2 { background: #E97132; }
.swatch-wml { background: #00B050; }
.swatch-social { background: #FFC000; }
.swatch-coaching { background: #00B0F0; }
.swatch-hampton { background: #808080; }
.swatch-hoe { background: #7030A0; }
.swatch-charity { background: #C00000; }
.swatch-festival { background: #000000; }
.swatch-open { background: #ECD4E9; }

@media (max-width: 768px) {
    .header-inner { padding: .65rem .875rem; }
    .header-nav { order: 3; width: 100%; flex-wrap: wrap; }
    .metrics-row { grid-template-columns: repeat(2,1fr); }
    .two-col { grid-template-columns: 1fr; }
    .piste-map { gap: .375rem; padding: .625rem; }
    .map-right { min-height: 100px; }
}
