/* ===================================================================
   CatchWatch Testing Platform — Stylesheet
   Clean, focused UI for standardised image annotation.
   =================================================================== */

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

:root {
    --color-bg:        #f5f6fa;
    --color-surface:   #ffffff;
    --color-text:      #2d3436;
    --color-muted:     #636e72;
    --color-primary:   #0984e3;
    --color-primary-h: #0767b3;
    --color-success:   #00b894;
    --color-warning:   #fdcb6e;
    --color-danger:    #d63031;
    --color-border:    #dfe6e9;
    --radius:          8px;
    --shadow:          0 2px 8px rgba(0,0,0,.08);
    --font:            -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---- Navbar ---- */
.navbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 12px 0;
    position: sticky; top: 0; z-index: 100;
}
.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
}
.user-badge {
    font-weight: 600;
    color: var(--color-muted);
    margin-right: 12px;
    font-size: .9rem;
}
.navbar nav { display: flex; align-items: center; gap: 8px; }

/* ---- Footer ---- */
footer {
    margin-top: auto;
    padding: 24px 0;
    text-align: center;
    color: var(--color-muted);
    font-size: .85rem;
    border-top: 1px solid var(--color-border);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: .95rem;
    font-weight: 600;
    text-decoration: none;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all .15s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-h); }
.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-outline:hover:not(:disabled) { background: var(--color-primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-block { display: flex; width: 100%; }

/* ---- Cards ---- */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card h1, .card h2 { margin-bottom: 12px; }

.subtitle {
    color: var(--color-muted);
    margin-bottom: 20px;
    font-size: .95rem;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: .9rem;
}
.form-group input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    transition: border-color .15s;
}
.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
}
.optional { font-weight: 400; color: var(--color-muted); }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-weight: 500;
}
.alert-warning { background: #fff3cd; color: #856404; }
.alert-info    { background: #d1ecf1; color: #0c5460; }

/* ---- Messages ---- */
.messages { margin-top: 16px; }

/* ---- Login page ---- */
.login-card { max-width: 480px; margin: 60px auto; }
.login-card h1 { text-align: center; }
.login-form { margin-top: 20px; }
.info-box {
    margin-top: 24px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: var(--radius);
    font-size: .9rem;
}
.info-box h3 { margin-bottom: 8px; font-size: .95rem; }
.info-box ul { padding-left: 20px; }
.info-box li { margin-bottom: 4px; }

/* ---- Dashboard ---- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}
@media (max-width: 640px) { .dashboard-grid { grid-template-columns: 1fr; } }

.stat-list { list-style: none; }
.stat-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: .95rem;
}
.stat-list li:last-child { border-bottom: none; }

/* ---- Table ---- */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}
.table th, .table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border);
}
.table th { font-weight: 600; font-size: .85rem; color: var(--color-muted); }

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: .8rem;
    font-weight: 600;
}
.badge-completed  { background: #d4edda; color: #155724; }
.badge-in_progress { background: #d1ecf1; color: #055160; }
.badge-abandoned  { background: #f8d7da; color: #721c24; }

/* ---- Test Interface ---- */
.test-header { margin-top: 16px; }
.progress-bar-wrapper {
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-bar {
    height: 100%;
    background: var(--color-primary);
    border-radius: 3px;
    transition: width .3s;
}
.test-meta {
    display: flex;
    justify-content: space-between;
    font-size: .85rem;
    color: var(--color-muted);
    margin-bottom: 12px;
}

/* Timer bar */
.timer-bar {
    position: relative;
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 16px;
}
.timer-fill {
    height: 100%;
    background: var(--color-success);
    border-radius: 4px;
    width: 100%;
    transition: width .1s linear;
}
.timer-fill.warning { background: var(--color-warning); }
.timer-fill.danger  { background: var(--color-danger); }
.timer-text {
    position: absolute;
    right: 4px;
    top: -20px;
    font-size: .85rem;
    font-weight: 700;
    color: var(--color-muted);
}

/* Image display */
.test-card { margin-top: 0; }
.image-container {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 300px;
}
.annotation-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    display: block;
}
.image-label {
    font-size: .85rem;
    color: var(--color-muted);
    text-align: center;
    margin-bottom: 16px;
}

/* Species selection grid */
.species-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 6px;
}
.species-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 6px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    cursor: pointer;
    transition: all .15s;
    font-family: var(--font);
    text-align: center;
    min-height: 62px;
}
.species-btn:hover {
    border-color: var(--color-primary);
    background: #e8f4fd;
}
.species-btn.selected {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}
.species-code {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.species-name {
    font-size: .75rem;
    margin-top: 2px;
    opacity: 0.85;
}

.annotation-input {
    font-size: 1.1rem !important;
    text-align: center;
}

.test-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}
.test-actions .btn { min-width: 120px; }

/* ---- Break page ---- */
.break-card { max-width: 520px; margin: 40px auto; text-align: center; }
.break-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 24px 0;
}
.stat { text-align: center; }
.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}
.stat-label {
    display: block;
    font-size: .85rem;
    color: var(--color-muted);
    margin-top: 4px;
}
.break-timer-box {
    background: #f8f9fa;
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}
.break-countdown {
    font-size: 3rem;
    font-weight: 700;
    color: var(--color-primary);
}
.break-hint {
    font-size: .9rem;
    color: var(--color-muted);
}
.break-note {
    font-size: .85rem;
    color: var(--color-muted);
    margin-top: 16px;
}

/* ---- Complete page ---- */
.complete-card { max-width: 520px; margin: 40px auto; text-align: center; }
.complete-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 24px 0 32px;
}
.complete-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    color: var(--color-muted);
    padding: 40px 0;
    font-size: 1.1rem;
}

/* ---- Disable text selection during test ---- */
.test-card {
    user-select: none;
    -webkit-user-select: none;
}

/* ---- Shared organiser shell ---- */
.admin-navbar { background: #1a1a2e; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; height: 48px; }
.admin-navbar .brand { color: #fff; font-weight: 700; text-decoration: none; font-size: .95rem; }
.admin-navbar .links { display: flex; gap: 8px; align-items: center; }
.admin-navbar .links a { color: #ccc; text-decoration: none; font-size: .85rem; }
.admin-navbar .links a:hover { color: #fff; }
.admin-layout { display: flex; min-height: calc(100vh - 48px); }
.admin-sidebar { width: 220px; background: #1a1a2e; color: #ccc; padding: 20px 0; flex-shrink: 0; }
.admin-sidebar a { display: block; padding: 10px 20px; color: #aaa; text-decoration: none; font-size: .9rem; transition: all .15s; }
.admin-sidebar a:hover, .admin-sidebar a.active { color: #fff; background: rgba(255,255,255,.08); }
.admin-main { flex: 1; padding: 24px 32px; max-width: 1200px; }
@media (max-width: 700px) {
    .admin-layout { display: block; }
    .admin-sidebar { width: 100%; display: flex; overflow-x: auto; padding: 0; }
    .admin-sidebar a { white-space: nowrap; padding: 10px 14px; }
    .admin-main { padding: 18px 14px; }
}

/* ---- Fill-level review workspace ---- */
.fill-review-link { border-left: 3px solid var(--color-warning); }
.top-bar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fill-review-page { min-height: calc(100vh - 56px); }
.fill-review-toolbar {
    display: flex; align-items: end; justify-content: space-between; gap: 16px;
    flex-wrap: wrap; margin-bottom: 16px;
}
.fill-review-toolbar h1 { margin-bottom: 4px; }
.fill-review-toolbar .subtitle { margin: 0; }
.fill-review-autosave-note { margin-top: 6px; color: #055160; font-size: .8rem; }
.fill-review-filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.fill-review-filters label { display: flex; flex-direction: column; gap: 4px; font-size: .75rem; font-weight: 700; color: var(--color-muted); }
.fill-review-filters select { min-width: 170px; padding: 9px 10px; border: 2px solid var(--color-border); border-radius: 6px; background: #fff; font: inherit; }
.fill-review-status { min-height: 24px; margin-bottom: 12px; font-size: .85rem; color: var(--color-muted); }
.fill-review-status.error { color: var(--color-danger); font-weight: 600; }
.fill-review-status.saved { color: #087f5b; }
.fill-review-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.fill-review-stage { background: #101418; border-radius: var(--radius); min-height: min(68vh, 720px); display: flex; align-items: center; justify-content: center; padding: 18px; overflow: hidden; }
.fill-review-stage img { display: block; max-width: 100%; max-height: min(64vh, 680px); width: auto; height: auto; object-fit: contain; transform-origin: center center; transition: transform .08s ease-out; user-select: none; -webkit-user-select: none; }
.fill-review-stage img.is-zoomed { cursor: grab; transition: none; touch-action: none; }
.fill-review-stage img.is-zoomed:active { cursor: grabbing; }
.fill-review-empty { color: #c8d0d8; text-align: center; padding: 48px 20px; }
.fill-review-empty strong { display: block; color: #fff; font-size: 1.15rem; margin-bottom: 6px; }
.fill-review-empty.success { color: #b8f2d5; }
.fill-review-empty.success strong { color: #d4f8e5; }
.fill-review-panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.fill-review-panel h2 { font-size: 1.05rem; margin-bottom: 3px; overflow-wrap: anywhere; }
.fill-review-meta { color: var(--color-muted); font-size: .82rem; margin-bottom: 18px; }
.fill-review-choice { width: 100%; text-align: left; margin: 6px 0; padding: 11px 12px; border: 2px solid var(--color-border); border-radius: 6px; background: #fff; color: var(--color-text); cursor: pointer; font: inherit; transition: border-color .15s, background .15s; }
.fill-review-choice:hover, .fill-review-choice.selected { border-color: var(--color-primary); background: #e8f4fd; }
.fill-review-choice:disabled { opacity: .6; cursor: wait; }
.fill-review-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; }
.fill-review-nav .btn { width: 100%; }
.fill-review-counter { font-size: .8rem; color: var(--color-muted); text-align: center; margin-top: 10px; }
.fill-review-progress { height: 6px; background: var(--color-border); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.fill-review-progress span { display: block; height: 100%; background: var(--color-primary); transition: width .2s; }
@media (max-width: 820px) {
    .fill-review-layout { grid-template-columns: 1fr; }
    .fill-review-stage { min-height: 48vh; }
    .fill-review-stage img { max-height: 44vh; }
}
@media (max-width: 560px) {
    .fill-review-filters, .fill-review-filters label, .fill-review-filters select { width: 100%; }
    .fill-review-stage { padding: 8px; }
}
