/*
    Teachquizly teacher panel: one stylesheet for the whole panel. Plain CSS, no framework, light only.
    Brand colours: navy ink for text, primary buttons and selected states; the brand red (--accent) only for small
    decorative marks, never for something that could read as "wrong". Errors keep their own red (--danger) and their
    alert styling. Cream page, cream cards, warm borders.
*/

:root {
    --brand: #211c32;
    --brand-dark: #100d1a;
    --brand-light: #e4dfdb;
    --brand-soft: #f3eee5;
    --accent: #ae4030;
    --text: #211c32;
    --muted: #5e5869;
    --border: #e5ded0;
    --border-strong: #d3c9b5;
    --bg: #f6f2e9;
    --card: #fffbf3;
    --field: #fff;
    --row-hover: #f8f3ea;
    --neutral-bg: #ece9ef;
    --neutral-text: #48435a;
    --danger: #b3261e;
    --danger-light: #fdecea;
    --success: #1f7a4d;
    --success-light: #e5f6ec;
    --warning: #8a5a00;
    --warning-light: #fff4d6;
    --info: #1d5fa8;
    --info-light: #e8f1fc;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(33, 28, 50, 0.07), 0 1px 2px rgba(33, 28, 50, 0.04);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    line-height: 1.45;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    line-height: 1.2;
    margin: 0 0 0.75rem;
}

h1 {
    font-size: 1.6rem;
}

h2 {
    font-size: 1.2rem;
}

h3 {
    font-size: 1.05rem;
}

h1:focus {
    outline: none;
}

/* Links are navy like the text, so they keep an underline to stay recognisable. */
a {
    color: var(--brand);
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    text-decoration-color: rgba(33, 28, 50, 0.35);
}

a:hover {
    text-decoration-color: currentColor;
}

p {
    margin: 0 0 0.75rem;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.875rem;
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ---- Page structure ---- */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
}

.page-header h1 {
    margin: 0;
}

.page-header .subtitle {
    margin: 0.35rem 0 0;
    color: var(--muted);
}

.actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.breadcrumb {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: var(--muted);
}

.breadcrumb a {
    font-weight: 500;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}

.card > h2:first-child,
.card-head h2 {
    margin-bottom: 0.75rem;
}

.card-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.card-head h2 {
    margin: 0;
}

.narrow {
    max-width: 420px;
    margin: 2rem auto;
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.grid-cards {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}

.stack > * + * {
    margin-top: 0.75rem;
}

/* ---- Buttons ---- */

.btn,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-strong);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.95rem;
    text-decoration: none;
    line-height: 1.2;
    transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}

.btn:hover,
button:hover {
    border-color: #b9ad96;
    background: var(--brand-soft);
}

.btn:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 3px solid rgba(33, 28, 50, 0.3);
    outline-offset: 1px;
}

.btn:disabled,
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn-primary,
button.primary {
    background: var(--brand);
    border-color: var(--brand);
    color: var(--card);
    font-weight: 600;
}

.btn-primary:hover,
button.primary:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    font-weight: 600;
}

.btn-success:hover {
    background: #17623d;
    border-color: #17623d;
}

.btn-danger {
    color: var(--danger);
    border-color: #f1c4c0;
}

.btn-danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.btn-big {
    padding: 0.85rem 1.4rem;
    font-size: 1.05rem;
    border-radius: 10px;
}

.btn-small {
    padding: 0.3rem 0.65rem;
    font-size: 0.85rem;
}

.btn-link {
    border: none;
    background: none;
    color: var(--brand);
    padding: 0.2rem 0.3rem;
    text-decoration: underline;
}

.btn-link:hover {
    background: none;
}

button.primary.full,
.btn.full {
    width: 100%;
}

/* ---- Forms ---- */

label {
    display: block;
    margin: 0.75rem 0 0.3rem;
    font-weight: 500;
}

label.inline,
.check {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

input:not([type=checkbox]):not([type=radio]),
select,
textarea {
    display: block;
    width: 100%;
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    font: inherit;
    font-size: 1rem;
    background: var(--field);
    color: var(--text);
}

textarea {
    min-height: 7rem;
    resize: vertical;
}

input[type=checkbox],
input[type=radio] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--brand);
    margin: 0;
    flex: none;
}

.field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.field-row label {
    margin-top: 0;
}

.hint {
    font-size: 0.85rem;
    color: var(--muted);
    margin-top: 0.25rem;
}

.inline-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.inline-form > * {
    flex: 1 1 140px;
}

.inline-form > button,
.inline-form > .btn {
    flex: 0 0 auto;
}

.inline-form label {
    margin-top: 0;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid,
input.invalid {
    outline: 2px solid var(--danger);
    border-color: var(--danger) !important;
}

.validation-message {
    color: var(--danger);
    font-size: 0.875rem;
}

/* ---- Feedback ---- */

.alert {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 10px;
    background: var(--danger-light);
    color: var(--danger);
    margin-bottom: 1rem;
}

.alert-info {
    background: var(--info-light);
    color: var(--info);
}

.alert-success {
    background: var(--success-light);
    color: var(--success);
}

.alert-warning {
    background: var(--warning-light);
    color: var(--warning);
}

.loading {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
    padding: 1rem 0;
}

.spinner {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 50%;
    border: 2px solid var(--brand-light);
    border-top-color: var(--brand);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty {
    text-align: center;
    color: var(--muted);
    padding: 1.5rem 1rem;
}

.empty .btn {
    margin-top: 0.75rem;
}

/* ---- Badges, chips, scores ---- */

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--neutral-bg);
    color: var(--neutral-text);
    white-space: nowrap;
    vertical-align: middle;
}

.badge-draft {
    background: var(--neutral-bg);
    color: var(--neutral-text);
}

.badge-open {
    background: var(--success-light);
    color: var(--success);
}

.badge-closed {
    background: #f2f0ec;
    color: #6b5f4b;
}

.badge-new {
    background: #ffe6e0;
    color: #b42318;
}

.badge-manual {
    background: var(--warning-light);
    color: var(--warning);
}

/* Topic category chips (CategoryBadge on the new-quiz page): three distinct hues; vocabulary is a warm ochre. */
.cat-grammar {
    background: #e8f1fc;
    color: #1d5fa8;
}

.cat-vocabulary {
    background: #f8edd6;
    color: #7a5410;
}

.cat-functional {
    background: #e6f6f3;
    color: #12715f;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    background: var(--brand-soft);
    border: 1px solid var(--brand-light);
    font-size: 0.85rem;
}

.score {
    display: inline-block;
    min-width: 3.4rem;
    text-align: center;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.9rem;
}

.score-high {
    background: var(--success-light);
    color: var(--success);
}

.score-mid {
    background: var(--warning-light);
    color: var(--warning);
}

.score-low {
    background: var(--danger-light);
    color: var(--danger);
}

.score-none {
    background: var(--neutral-bg);
    color: var(--muted);
}

/* ---- Stats ---- */

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
}

.stat .value {
    font-size: 1.6rem;
    font-weight: 700;
}

.stat .label {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---- Tables ---- */

.table-wrap {
    overflow-x: auto;
    margin: 0 -0.25rem;
}

table.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th,
.table td {
    text-align: left;
    padding: 0.6rem 0.6rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--row-hover);
}

.table tr.is-new td:first-child {
    box-shadow: inset 3px 0 0 #f04438;
}

.table tr.inactive td {
    color: var(--muted);
}

.table .num {
    text-align: right;
    white-space: nowrap;
}

.table .center {
    text-align: center;
}

.table a.row-link {
    font-weight: 600;
}

.table input.score-input {
    display: inline-block;
    width: 6.5rem;
    text-align: right;
    padding: 0.4rem 0.5rem;
}

th.sortable {
    cursor: pointer;
    user-select: none;
}

/* ---- Tabs and segmented controls ---- */

.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
    overflow-x: auto;
}

.tabs a,
.tabs button {
    border: none;
    background: none;
    border-radius: 0;
    padding: 0.6rem 0.9rem;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    text-decoration: none;
    white-space: nowrap;
    font-weight: 500;
}

.tabs a:hover,
.tabs button:hover {
    color: var(--text);
    background: none;
}

.tabs .active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card);
}

.segmented button {
    border: none;
    border-radius: 0;
    border-right: 1px solid var(--border);
    padding: 0.55rem 0.95rem;
}

.segmented button:last-child {
    border-right: none;
}

.segmented button.selected {
    background: var(--brand);
    color: var(--card);
    font-weight: 600;
}

.segmented button .count {
    font-size: 0.78rem;
    opacity: 0.8;
    margin-left: 0.15rem;
}

/* ---- Lists of things (cards that are links) ---- */

.tile {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow);
    transition: border-color 0.12s, transform 0.12s;
}

a.tile:hover {
    border-color: var(--brand);
    transform: translateY(-1px);
}

.tile .tile-title {
    font-weight: 700;
    font-size: 1.15rem;
    margin-bottom: 0.25rem;
}

.tile.archived {
    opacity: 0.65;
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list > li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.list > li:last-child {
    border-bottom: none;
}

.list .grow {
    flex: 1;
    min-width: 0;
}

.list .title {
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
}

.list a.title:hover {
    text-decoration: underline;
}

.meta {
    color: var(--muted);
    font-size: 0.85rem;
}

/* ---- Quiz builder ---- */

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 0.75rem;
}

.mode-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 0.3rem;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    height: 100%;
}

.mode-card:hover {
    border-color: #b9ad96;
}

.mode-card.selected {
    border-color: var(--brand);
    background: var(--brand-soft);
    box-shadow: 0 0 0 3px rgba(33, 28, 50, 0.1);
}

.mode-card .mode-icon {
    font-size: 1.5rem;
}

.mode-card .mode-title {
    font-weight: 700;
    font-size: 1.02rem;
}

.mode-card .mode-text {
    color: var(--muted);
    font-size: 0.87rem;
}

.level-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.level-toggle {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 7.5rem;
    padding: 0.6rem 0.9rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    cursor: pointer;
}

.level-toggle .code {
    font-weight: 800;
    font-size: 1.2rem;
}

.level-toggle .name {
    font-size: 0.8rem;
    color: var(--muted);
}

.level-toggle.selected {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.level-toggle.selected .code {
    color: var(--brand);
}

.level-toggle:disabled {
    cursor: not-allowed;
}

.topic-panel {
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 0.75rem;
    background: var(--card);
}

.panel-summary {
    padding: 0.7rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.topic-panel .panel-body {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1rem 1rem;
}

.topic-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
    align-items: center;
}

.topic-toolbar input[type=search] {
    max-width: 260px;
    padding: 0.35rem 0.6rem;
    font-size: 0.9rem;
}

.unit-group + .unit-group {
    margin-top: 0.6rem;
}

.unit-title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.4rem 0 0.25rem;
}

.topic-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-radius: 8px;
    margin: 0;
    font-weight: 400;
    cursor: pointer;
}

.topic-row:hover {
    background: var(--brand-soft);
}

.topic-row input {
    margin-top: 0.15rem;
}

.topic-row .topic-name {
    font-weight: 600;
}

.topic-row .topic-desc {
    display: block;
    font-size: 0.83rem;
    color: var(--muted);
}

.topic-row .topic-count {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--muted);
    white-space: nowrap;
}

.topic-row.excluded .topic-name {
    color: var(--muted);
    text-decoration: line-through;
}

.topic-row.empty-topic {
    opacity: 0.55;
}

.summary-bar {
    position: sticky;
    bottom: 0;
    z-index: 20;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 -4px 16px rgba(33, 28, 50, 0.08);
    padding: 0.9rem 1.1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.summary-bar .availability {
    font-size: 0.98rem;
}

.summary-bar .availability strong {
    font-size: 1.15rem;
}

.ok-text {
    color: var(--success);
}

.warn-text {
    color: var(--warning);
}

.bad-text {
    color: var(--danger);
}

.count-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.count-input input {
    width: 6rem !important;
    display: inline-block !important;
    text-align: center;
    font-size: 1.1rem !important;
    font-weight: 700;
}

/* ---- Attempt detail ---- */

.question {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.9rem 1rem;
    background: var(--card);
}

.question + .question {
    margin-top: 0.75rem;
}

.question.correct {
    border-left: 4px solid var(--success);
}

.question.wrong {
    border-left: 4px solid var(--danger);
}

.question-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.4rem;
}

.question-prompt {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 0.25rem 0 0.6rem;
    white-space: pre-wrap;
}

.options {
    list-style: none;
    padding: 0;
    margin: 0 0 0.5rem;
    display: grid;
    gap: 0.3rem;
}

.options li {
    padding: 0.4rem 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.options li.is-correct {
    border-color: #9fd8b8;
    background: var(--success-light);
}

.options li.is-picked-wrong {
    border-color: #f1b4ae;
    background: var(--danger-light);
}

.options .marker {
    margin-left: auto;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.answer-box {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.75rem;
    font-size: 0.95rem;
}

.answer-box dt {
    color: var(--muted);
}

.answer-box dd {
    margin: 0;
}

/* ---- Grade book ---- */

.gradebook {
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.92rem;
}

.gradebook th,
.gradebook td {
    border-bottom: 1px solid var(--border);
    padding: 0.5rem 0.6rem;
    white-space: nowrap;
}

.gradebook th.student,
.gradebook td.student {
    position: sticky;
    left: 0;
    background: var(--card);
    z-index: 1;
    text-align: left;
    min-width: 11rem;
}

.gradebook thead th {
    font-size: 0.8rem;
    color: var(--muted);
    vertical-align: bottom;
    text-align: center;
}

.gradebook thead th a {
    display: block;
    max-width: 9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.gradebook thead th a:hover {
    text-decoration: underline;
}

.gradebook td.cell {
    text-align: center;
}

.gradebook td.avg,
.gradebook th.avg {
    font-weight: 700;
    background: var(--brand-soft);
}

/* ---- Question bank ---- */

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.6rem;
    align-items: end;
}

.filters label {
    margin-top: 0;
    font-size: 0.85rem;
}

.pager {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    justify-content: center;
    margin-top: 1rem;
}

/* ---- Small screens ---- */

@media (max-width: 760px) {
    h1 {
        font-size: 1.35rem;
    }

    .card {
        padding: 1rem;
    }

    .page-header .actions {
        width: 100%;
    }

    .summary-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .summary-bar .btn {
        width: 100%;
    }

    .table th,
    .table td {
        padding: 0.5rem 0.4rem;
    }

    .hide-sm {
        display: none;
    }
}

@media print {
    body {
        background: #fff;
    }

    .no-print {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: none;
    }
}

/* ---- Blazor ---- */

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 1.5rem;
    color: white;
    border-radius: 8px;
}

.blazor-error-boundary::after {
    content: "Bu bölümde bir hata oluştu. Sayfayı yenileyin.";
}

/* ---- Legal links (footer of every page, note under the login form) ---- */

.legal-foot {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 1rem 2rem;
    font-size: 0.85rem;
}

.legal-foot a {
    color: var(--muted);
}

.legal-foot a:hover {
    color: var(--text);
}

.login-legal {
    margin-top: 1rem;
    font-size: 0.85rem;
}
