/* Tennis Tracker — shared styles for Login.html, App.html and ResetPassword.html */

* { box-sizing: border-box; }

/* The JS toggles visibility with the `hidden` property; make sure no element
   rule can out-specify the UA default of display:none. */
[hidden] { display: none !important; }

:root {
    --bg: #f1f4f2;
    --panel: #ffffff;
    --border: #d7ded9;
    --text: #1f2723;
    --text-muted: #6b7a71;
    --primary: #2f7d4f;
    --primary-dark: #235f3c;
    --danger: #b3372f;
    --accent: #cddc39;   /* tennis-ball yellow-green, used sparingly */
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
}

h1, h2, h3 { margin: 0 0 12px; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

button {
    font: inherit;
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    border: 1px solid transparent;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.button-primary { background: var(--primary); color: #fff; }
.button-primary:hover:not(:disabled) { background: var(--primary-dark); }
.button-secondary { background: var(--panel); color: var(--text); border-color: var(--border); }
.button-secondary:hover:not(:disabled) { background: var(--bg); }
.button-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.button-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"], select, textarea {
    font: inherit;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }

label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }

.empty-note { color: var(--text-muted); font-style: italic; }
.error-note { color: var(--danger); }
.info-note { color: var(--primary); }

/* An upload that was cut off by a screen lock or a closed tab is reported on
   the next load. Full width above the layout, because the panel it belonged to
   no longer exists by then. */
.interrupted-note {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1200px;
    margin: 20px auto -8px;
    padding: 12px 16px;
    background: var(--panel);
    border: 1px solid var(--danger);
    border-radius: 12px;
}
.interrupted-note p { margin: 0; color: var(--danger); }
.interrupted-note button { flex: none; }
@media (max-width: 820px) {
    .interrupted-note { margin: 12px 20px -8px; }
}

/* --- header + layout --- */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
}
.app-header h1 { margin: 0; }
.header-user { display: flex; align-items: center; gap: 12px; color: var(--text-muted); }

.app-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}
@media (max-width: 820px) {
    .app-layout { grid-template-columns: 1fr; }
}

/* --- sidebar --- */

.sidebar, .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}
.sidebar { align-self: start; }

/* Tabs switch the sidebar between trainings and matches. */
.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--border);
}
.tab {
    flex: 1;
    background: transparent;
    border: none;
    border-radius: 8px 8px 0 0;
    padding: 9px 10px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}
.tab:hover:not(.selected) { background: var(--bg); }
.tab.selected { color: var(--primary); border-bottom-color: var(--primary); }

.entry-list { list-style: none; margin: 0 0 20px; padding: 0; }
.entry-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
}
.entry-item:hover { background: var(--bg); }
.entry-item.selected { background: #e2efe7; }
.entry-item .entry-main { flex: 1; min-width: 0; }
.entry-date { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.entry-sub {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.entry-count { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Win/loss/draw at a glance in the match list. */
.result-badge {
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 999px;
    color: #fff;
}
.result-win { background: var(--primary); }
.result-loss { background: var(--danger); }
.result-draw { background: var(--text-muted); }

.form-grid { display: grid; gap: 10px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-actions { display: flex; gap: 8px; align-items: center; }

/* --- training / match detail --- */

.detail-stack { display: grid; gap: 20px; }
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

/* --- notes: Markdown source / rendered toggle --- */

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}
.notes-toggle { display: flex; gap: 2px; }
.notes-tab {
    font-size: 12px;
    padding: 3px 9px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
}
.notes-tab:hover:not(.selected) { background: var(--bg); }
.notes-tab.selected { background: var(--bg); border-color: var(--border); color: var(--text); }

/* Sits in the notes toggle row, styled like a tab but always clickable. */
.ai-rewrite {
    font-size: 12px;
    padding: 3px 9px;
    margin-right: 8px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
}
.ai-rewrite:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.ai-rewrite:disabled { opacity: 0.6; cursor: default; }

/* --- settings dialog --- */

.settings-dialog {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: min(420px, 90vw);
    background: var(--panel);
    color: var(--text);
}
.settings-dialog::backdrop { background: rgba(31, 39, 35, 0.45); }
.settings-dialog h2 { margin: 0 0 4px; }
.settings-dialog h3 { margin: 12px 0 8px; font-size: 15px; }
.settings-dialog label { margin-top: 10px; }
.settings-dialog input, .settings-dialog select { width: 100%; }
.settings-dialog .form-actions { margin-top: 16px; }
.settings-status { margin: 0 0 8px; font-size: 13px; }
.settings-hint { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }

/* The rendered view stands in for the textarea, so it matches its box. */
.notes-preview {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    min-height: 70px;
    background: #fff;
    cursor: text;
    overflow-wrap: break-word;
}
.notes-preview > :first-child { margin-top: 0; }
.notes-preview > :last-child { margin-bottom: 0; }
.notes-preview p { margin: 0 0 8px; }
.notes-preview h1, .notes-preview h2, .notes-preview h3,
.notes-preview h4, .notes-preview h5, .notes-preview h6 { margin: 12px 0 6px; font-size: 14px; }
.notes-preview h1 { font-size: 18px; }
.notes-preview h2 { font-size: 16px; }
.notes-preview h3 { font-size: 15px; }
.notes-preview ul, .notes-preview ol { margin: 0 0 8px; padding-left: 22px; }
.notes-preview li { margin: 2px 0; }
.notes-preview a { color: var(--primary); }
.notes-preview hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.notes-preview blockquote {
    margin: 0 0 8px;
    padding-left: 10px;
    border-left: 3px solid var(--border);
    color: var(--text-muted);
}
.notes-preview code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 4px;
}
.notes-preview pre {
    margin: 0 0 8px;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow-x: auto;
}
.notes-preview pre code { background: none; border: none; padding: 0; }

/* --- media: videos and pictures --- */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.media-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}
.media-card video,
.media-card img {
    display: block;
    width: 100%;
    max-height: 320px;
    background: #000;
}
/* Pictures are letterboxed rather than cropped — a photo of a court is
   usually landscape, a phone photo of a serve usually is not. */
.media-card img { object-fit: contain; }
.speed-control {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 0;
    font-size: 12px;
    color: var(--text-muted);
}
.speed-button {
    padding: 2px 10px;
    font-size: 12px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.speed-button:hover { background: var(--bg); }
.speed-button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--text);
}
.bookmark-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 12px 0;
}
.bookmark-chips {
    display: contents;   /* chips share the row's flex flow and wrap with it */
}
.bookmark-chip {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    background: var(--panel);
}
.bookmark-jump, .bookmark-remove {
    border: none;
    background: none;
    font-size: 12px;
    padding: 3px 6px;
    cursor: pointer;
    color: var(--text);
}
.bookmark-jump { padding-left: 10px; }
.bookmark-jump:hover { background: var(--bg); }
.bookmark-remove {
    color: var(--text-muted);
    padding-right: 8px;
}
.bookmark-remove:hover { color: #b3392f; }
.bookmark-add {
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: none;
    color: var(--text-muted);
    font-size: 12px;
    padding: 3px 10px;
    cursor: pointer;
}
.bookmark-add:hover { background: var(--bg); color: var(--text); }
.media-meta { padding: 10px 12px; }
.media-meta h4 { margin: 0 0 4px; font-size: 15px; }
.media-sub { color: var(--text-muted); font-size: 12px; }
.media-notes { margin: 8px 0 0; font-size: 13px; white-space: pre-wrap; }
.media-actions { display: flex; gap: 8px; padding: 0 12px 12px; }

/* --- video comparison --- */

.compare-picker {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    width: min(560px, 92vw);
    max-height: 80vh;
    overflow-y: auto;
    background: var(--panel);
    color: var(--text);
}
.compare-picker::backdrop { background: rgba(31, 39, 35, 0.45); }
.compare-picker h2 { margin: 0 0 4px; }
.compare-picker h3 { margin: 14px 0 6px; font-size: 13px; color: var(--text-muted); text-transform: uppercase; }
.compare-picker .form-actions { margin-top: 16px; }
.compare-picker-current { margin: 0 0 8px; font-size: 13px; color: var(--text-muted); }
.compare-choice {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    width: 100%;
    margin-bottom: 6px;
    padding: 8px 12px;
    text-align: left;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text);
}
.compare-choice:hover { border-color: var(--primary); }
.compare-choice-title { font-size: 14px; font-weight: 600; }
.compare-choice-sub { font-size: 12px; color: var(--text-muted); }

/* True full viewport: a dialog's UA default max sizes (calc(100% - …)) must
   be overridden, or the "full-screen" view keeps a margin. */
.compare-dialog {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    margin: 0;
    padding: 16px;
    border: none;
    background: var(--bg);
    color: var(--text);
}
.compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.compare-header h2 { margin: 0; }
.compare-videos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    flex: 1;
    overflow-y: auto;
    align-content: start;
}
@media (max-width: 820px) {
    .compare-videos { grid-template-columns: 1fr; }
}
.compare-side video {
    display: block;
    width: 100%;
    max-height: 62vh;
    background: #000;
    border-radius: 8px;
}
.compare-side-label { margin: 0 0 6px; font-size: 13px; color: var(--text-muted); }
.compare-side-label strong { color: var(--text); }
.compare-side .bookmark-row { padding: 8px 0 0; }
.nudge-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0 0;
    font-size: 12px;
    color: var(--text-muted);
}
.nudge-button {
    padding: 2px 10px;
    font-size: 12px;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
}
.nudge-button:hover { background: var(--bg); }
.compare-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid var(--border);
}
.compare-controls .speed-control { padding: 0; }

.upload-progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--bg);
    overflow: hidden;
    border: 1px solid var(--border);
}
.upload-progress > div {
    height: 100%;
    width: 0;
    background: var(--primary);
    transition: width 0.15s linear;
}

/* --- login --- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-container {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px;
    width: 100%;
    max-width: 380px;
}
.login-container h1 { text-align: center; margin-bottom: 20px; }
.form-group { margin-bottom: 14px; }
.login-button { width: 100%; margin-top: 6px; }
.auth-toggle { text-align: center; font-size: 14px; color: var(--text-muted); }
.auth-toggle a { color: var(--primary); }
