/* DubsDeck — Global Stylesheet
   Mobile-only app. All styles live here.
   Split into sections if this file grows unwieldy. */

/* =============================================================================
   Base / Reset
============================================================================= */

/* Global layout tokens — adjust these to shift all dependent offsets at once */
:root {
    --header-height: 69px;       /* rendered height of .app-header */
    --summary-bar-height: 45px;  /* rendered height of .night-summary-bar */
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    /* Explicit background-color prevents browser default (white/gray) from
       showing through on any viewport size or during page load */
    background-color: #0f1115;
    color: #e8eaed;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

/* =============================================================================
   Layout
============================================================================= */

/* Centers a single-column content block vertically and horizontally.
   Used by login and other full-screen single-action pages. */
.page-center {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* Standard content card — white-on-dark panel for forms and content blocks */
.card {
    background: #1c1f26;
    border-radius: 12px;
    padding: 32px 24px;
    width: 100%;
    max-width: 400px;
}

/* =============================================================================
   Typography
============================================================================= */

h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25em;
}

h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.text-muted {
    opacity: 0.5;
    font-size: 0.85rem;
}

/* =============================================================================
   Branding
============================================================================= */

/* Logo + app name block used at the top of the login card */
.brand {
    text-align: center;
    margin-bottom: 24px;
}

.brand img {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 10px;
}

.brand h2 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin-bottom: 0;
}

/* =============================================================================
   Forms
============================================================================= */

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0.8;
}

.form-group input {
    background: #0f1115;
    border: 1px solid #2e3240;
    border-radius: 8px;
    color: #e8eaed;
    font-size: 1rem;
    padding: 12px 14px;
    width: 100%;
    /* Prevents iOS zoom on focus by keeping font-size at 16px */
    -webkit-appearance: none;
}

.form-group input:focus {
    border-color: #5b8dee;
    outline: none;
}

/* =============================================================================
   Buttons
============================================================================= */

.btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    padding: 13px 20px;
    width: 100%;
    transition: opacity 0.15s ease;
}

.btn:active {
    opacity: 0.8;
}

.btn-primary {
    background: #00C2B2;
    color: #fff;
}

.btn-primary:hover {
    background: #00a99a;
}

/* =============================================================================
   Alerts
============================================================================= */

/* Inline error message shown on failed form submissions */
.alert-error {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.4);
    border-radius: 8px;
    color: #f08090;
    font-size: 0.9rem;
    margin-bottom: 16px;
    padding: 12px 14px;
}

/* =============================================================================
   App Header & Nav Menu — shared across all pages
============================================================================= */

/* Fixed top bar — brand left, hamburger right */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: #0f1115;
    border-bottom: 1px solid #2e3240;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.app-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #00C2B2;
}

/* Hamburger button — no browser chrome, 44px tap target */
.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
}

/* Each of the three bars */
.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: #e8eaed;
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
    transform-origin: center;
}

/* X animation when menu is open: rotate top and bottom bars, hide middle */
.hamburger--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger--open span:nth-child(2) { opacity: 0; }
.hamburger--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Full-width slide-down nav panel — closed by default via max-height: 0 */
.nav-menu {
    position: fixed;
    top: calc(var(--header-height) + env(safe-area-inset-top)); /* sits directly below .app-header */
    left: 0;
    right: 0;
    background: #1c1f26;
    border-bottom: 1px solid #2e3240;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.25s ease;
    z-index: 99;
}

/* Open state — max-height large enough to reveal all nav items */
.nav-menu--open {
    max-height: 300px;
}

/* Individual nav link — full-width, generous tap target */
.nav-item {
    display: block;
    padding: 16px 20px;
    color: #e8eaed;
    font-size: 1rem;
    text-decoration: none;
    border-bottom: 1px solid #2e3240;
    opacity: 0.7;
}

.nav-item:last-child {
    border-bottom: none;
}

.nav-item:active {
    background: rgba(255, 255, 255, 0.04);
}

/* Active page — teal color, full opacity, bold */
.nav-item--active {
    color: #00C2B2;
    font-weight: 600;
    opacity: 1;
}

/* Logout gets a slightly more muted treatment to deprioritize it visually */
.nav-item--logout {
    opacity: 0.4;
    font-size: 0.9rem;
}

/* Page title block — sits in document flow below the fixed header */
.page-title-bar {
    padding: calc(var(--header-height) + 16px + env(safe-area-inset-top)) 16px 0;
    max-width: 480px;
    margin: 0 auto;
}

/* Applied in State 2 only — clears both the fixed header and the fixed summary bar */
.page-title-bar--below-summary {
    padding-top: calc(var(--header-height) + var(--summary-bar-height) + 16px + env(safe-area-inset-top));
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    padding-bottom: 16px;
    border-bottom: 1px solid #2e3240;
    margin-bottom: 0;
}

/* =============================================================================
   Dashboard — Shared (both states)
============================================================================= */

/* Fixed top bar: brand wordmark left, logout link right */
.dashboard-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Respect iOS notch/status bar */
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top));
    background: #0f1115;
    border-bottom: 1px solid #2e3240;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
}

.dashboard-brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: #00C2B2;
}

.dashboard-logout {
    font-size: 0.85rem;
    color: #e8eaed;
    opacity: 0.5;
    text-decoration: none;
}

.dashboard-logout:active {
    opacity: 1;
}

/* Groups nav links (e.g. Players) and logout together on the right side */
.dashboard-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Secondary header nav link — same muted style as logout */
.dashboard-nav-link {
    font-size: 0.85rem;
    color: #e8eaed;
    opacity: 0.5;
    text-decoration: none;
}

.dashboard-nav-link:active {
    opacity: 1;
}

/* =============================================================================
   Dashboard — State 1: No Active Night
============================================================================= */

/* Scrollable content area — top offset is handled by .page-title-bar above it */
.dashboard-main {
    padding: 16px 16px 32px;
    max-width: 480px;
    margin: 0 auto;
}

/* Form wrapper for the start-night CTA — carries the bottom margin */
form:has(.btn-start-night) {
    margin-bottom: 32px;
}

/* The primary start-night CTA — larger than standard btn for prominence */
.btn-start-night {
    font-size: 1.15rem;
    padding: 18px 20px;
}

/* Secondary button style for Copy and other low-priority actions */
.btn-secondary {
    background: #2e3240;
    color: #e8eaed;
    font-size: 0.875rem;
    padding: 9px 16px;
    width: auto;
    border-radius: 8px;
}

.btn-secondary:active {
    opacity: 0.7;
}

/* Section heading above the prior nights list */
.night-list-heading {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.45;
    margin-bottom: 12px;
}

/* Container for the prior nights rows */
.night-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* One prior night: date/course/count left, Copy button right */
.night-row {
    background: #1c1f26;
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.night-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* allows text truncation */
}

.night-row-date {
    font-size: 0.8rem;
    opacity: 0.5;
}

.night-row-course {
    font-size: 0.95rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.night-row-count {
    font-size: 0.8rem;
    opacity: 0.45;
}

/* =============================================================================
   Dashboard — State 2: Active Night
============================================================================= */

/* Night summary bar — fixed directly below the header */
.night-summary-bar {
    position: fixed;
    /* Sits below the header */
    top: calc(var(--header-height) + env(safe-area-inset-top));
    left: 0;
    right: 0;
    background: #1c1f26;
    border-bottom: 1px solid #2e3240;
    padding: 10px 16px;
    z-index: 90;
}

.night-summary-course {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
}

.night-summary-meta {
    display: flex;
    gap: 14px;
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Scrollable check-in list — fills the space between summary bar and Make Teams bar */
.checkin-main {
    padding-top: calc(var(--header-height) + var(--summary-bar-height) + 12px + env(safe-area-inset-top));
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* The scrollable roster list itself */
.checkin-list {
    list-style: none;
    max-width: 480px;
    margin: 0 auto;
    padding: 0 8px;
}

/* One player row — flex row, min 52px for thumb target */
.checkin-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 52px;
    padding: 6px 8px;
    border-radius: 8px;
    border-left: 3px solid transparent;
    margin-bottom: 2px;
    transition: background 0.1s ease, border-color 0.15s ease;
}

/* Checked-in state: teal left accent, subtle background */
.checkin-row.checked-in {
    background: rgba(0, 194, 178, 0.07);
    border-left-color: #00C2B2;
}

/* Button that wraps tier badge + name — tap target for check-in toggle */
.checkin-name-btn {
    background: none;
    border: none;
    color: #e8eaed;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    padding: 0;
    cursor: pointer;
    text-align: left;
}

/* Checked-in name is slightly dimmed to indicate processed state */
.checkin-row.checked-in .checkin-name {
    opacity: 0.65;
}

.checkin-name {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tier badge pill */
.tier-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Tier color variants */
.tier-a { background: rgba(255, 193, 7,  0.2); color: #ffc107; }
.tier-b { background: rgba(0,  194, 178, 0.2); color: #00C2B2; }
.tier-c { background: rgba(148, 163, 184, 0.15); color: #94a3b8; }

/* Three-toggle cluster per player row */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Hidden until player is checked in */
.toggle-group--hidden {
    visibility: hidden;
    pointer-events: none;
}

/* Individual toggle label — wraps track + text label */
.toggle-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    cursor: pointer;
}

/* Visually hidden native checkbox — interaction handled by the track */
.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* The toggle track — pill shape, off state */
.toggle-track {
    display: block;
    width: 34px;
    height: 20px;
    background: #2e3240;
    border-radius: 10px;
    position: relative;
    transition: background 0.15s ease;
}

/* Thumb inside the track */
.toggle-track::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    background: #6b7280;
    border-radius: 50%;
    transition: transform 0.15s ease, background 0.15s ease;
}

/* Checked state — teal track, thumb slides right */
.toggle-label input:checked + .toggle-track {
    background: #00C2B2;
}

.toggle-label input:checked + .toggle-track::after {
    transform: translateX(14px);
    background: #fff;
}

.toggle-text {
    font-size: 0.6rem;
    opacity: 0.5;
    letter-spacing: 0.02em;
}

/* Fixed bottom bar holding the Make Teams button */
.make-teams-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    background: #0f1115;
    border-top: 1px solid #2e3240;
    z-index: 100;
}

.btn-make-teams {
    font-size: 1.05rem;
    padding: 15px 20px;
}

/* Disabled state for Make Teams — visible but clearly inactive */
.btn-make-teams:disabled {
    background: #2e3240;
    color: #6b7280;
    cursor: not-allowed;
    opacity: 1;
}

/* =============================================================================
   Players Page
============================================================================= */

/* Top margin on Add Player button to separate it from any error alert */
.btn-add-player {
    margin-bottom: 20px;
}

/* Inline form panel — hidden by default, revealed via JS toggle */
.form-panel {
    display: none;
    background: #1c1f26;
    border-radius: 12px;
    padding: 20px 16px;
    margin-bottom: 24px;
}

.form-panel--open {
    display: block;
}

.form-panel-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Row holding Save and Cancel buttons side by side */
.form-panel-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

/* Cancel button takes less visual weight than Save */
.form-panel-actions .btn-secondary {
    flex: 0 0 auto;
    width: auto;
    padding: 13px 20px;
}

.form-panel-actions .btn-primary {
    flex: 1;
}

/* Three-button A/B/C tier selector */
.tier-selector {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.tier-btn {
    flex: 1;
    background: #2e3240;
    border: 2px solid transparent;
    border-radius: 8px;
    color: #e8eaed;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    padding: 12px 0;
    text-align: center;
    transition: background 0.12s ease, border-color 0.12s ease;
}

/* Selected state for each tier uses the existing tier brand colors */
.tier-btn-a.tier-btn--selected {
    background: rgba(255, 193, 7,  0.15);
    border-color: #ffc107;
    color: #ffc107;
}

.tier-btn-b.tier-btn--selected {
    background: rgba(0,  194, 178, 0.15);
    border-color: #00C2B2;
    color: #00C2B2;
}

.tier-btn-c.tier-btn--selected {
    background: rgba(148, 163, 184, 0.12);
    border-color: #94a3b8;
    color: #94a3b8;
}

/* Player roster list */
.player-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* One player row: tier badge + name on the left, Edit on the right */
.player-row {
    background: #1c1f26;
    border-radius: 10px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.player-row-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.player-name {
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Empty state message when no players exist */
.empty-state {
    text-align: center;
    margin-top: 32px;
}
