/* ==========================================================================
   Python Exam Platform - shared base styles
   Plain CSS on purpose: there is no build step, so the application can be
   deployed to a classroom machine with nothing but PHP and MySQL.
   ========================================================================== */

:root {
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #dbe3ed;
    --border-strong: #c3cfdf;
    --text: #16233a;
    --muted: #64748b;
    --primary: #2457d6;
    --primary-dark: #1c46ad;
    --primary-soft: #e8eefc;
    --success: #157f4a;
    --success-soft: #e4f6ec;
    --warning: #a96410;
    --warning-soft: #fdf1de;
    --danger: #c02b2b;
    --danger-soft: #fdeaea;
    --flag: #7c3aed;
    --flag-soft: #f1e9fe;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(15, 32, 65, .06), 0 4px 14px rgba(15, 32, 65, .05);
    --shadow-lg: 0 10px 40px rgba(15, 32, 65, .14);
    --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "Courier New", monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
}

h1, h2, h3, h4 {
    margin: 0 0 .6rem;
    line-height: 1.25;
    font-weight: 650;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }

p { margin: 0 0 .8rem; }

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover { text-decoration: underline; }

/* --------------------------------------------------------------------------
   Layout helpers
   -------------------------------------------------------------------------- */

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.container-narrow {
    width: 100%;
    max-width: 460px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

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

.row {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
}

.row-between {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
}

.grow { flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny { font-size: .75rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* --------------------------------------------------------------------------
   Cards and panels
   -------------------------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card-body { padding: 1.15rem 1.25rem; }

.card-header {
    padding: .9rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    flex-wrap: wrap;
}

.card-header h2,
.card-header h3 { margin: 0; }

.card-footer {
    padding: .85rem 1.25rem;
    border-top: 1px solid var(--border);
    background: var(--surface-alt);
    border-radius: 0 0 var(--radius) var(--radius);
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .55rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.btn:hover {
    background: var(--primary-dark);
    text-decoration: none;
    color: #fff;
}

.btn:disabled,
.btn[aria-disabled="true"] {
    opacity: .55;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-alt);
    color: var(--text);
}

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #a12222; }

.btn-success { background: var(--success); }
.btn-success:hover { background: #10633a; }

.btn-sm {
    padding: .32rem .6rem;
    font-size: .8rem;
}

.btn-block { width: 100%; }

.btn-link {
    background: none;
    border: none;
    color: var(--primary);
    padding: 0;
    font: inherit;
    font-size: .82rem;
    cursor: pointer;
    text-decoration: underline;
}

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

.field { margin-bottom: 1rem; }

.field > label,
.label {
    display: block;
    margin-bottom: .3rem;
    font-weight: 600;
    font-size: .87rem;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: .55rem .7rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: 2px solid var(--primary);
    outline-offset: -1px;
    border-color: var(--primary);
}

.textarea {
    min-height: 110px;
    resize: vertical;
}

.textarea-code {
    font-family: var(--mono);
    font-size: .86rem;
    line-height: 1.5;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    min-height: 150px;
    tab-size: 4;
}

.help {
    display: block;
    margin-top: .3rem;
    font-size: .78rem;
    color: var(--muted);
}

.error {
    display: block;
    margin-top: .3rem;
    font-size: .8rem;
    color: var(--danger);
    font-weight: 500;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: .5rem;
    margin-bottom: .55rem;
    font-size: .9rem;
}

.checkbox input { margin-top: .25rem; }

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

/* --------------------------------------------------------------------------
   Alerts
   -------------------------------------------------------------------------- */

.alert {
    padding: .7rem .9rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: .88rem;
    margin-bottom: 1rem;
}

.alert-success {
    background: var(--success-soft);
    border-color: #b9e2cb;
    color: #0d5c36;
}

.alert-error {
    background: var(--danger-soft);
    border-color: #f2c2c2;
    color: #8e1f1f;
}

.alert-warning {
    background: var(--warning-soft);
    border-color: #f0d6a8;
    color: #834c07;
}

.alert-info {
    background: var(--primary-soft);
    border-color: #c3d3f7;
    color: #1b3f9c;
}

.alert ul {
    margin: .4rem 0 0;
    padding-left: 1.1rem;
}

/* --------------------------------------------------------------------------
   Badges
   -------------------------------------------------------------------------- */

.badge {
    display: inline-block;
    padding: .12rem .5rem;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 650;
    letter-spacing: .01em;
    white-space: nowrap;
    background: var(--surface-alt);
    color: var(--muted);
    border: 1px solid var(--border);
}

.badge-success { background: var(--success-soft); color: #0d5c36; border-color: #b9e2cb; }
.badge-warning { background: var(--warning-soft); color: #834c07; border-color: #f0d6a8; }
.badge-danger  { background: var(--danger-soft);  color: #8e1f1f; border-color: #f2c2c2; }
.badge-progress{ background: var(--primary-soft); color: #1b3f9c; border-color: #c3d3f7; }
.badge-muted   { background: #eceff4; color: #5a6678; }
.badge-flag    { background: var(--flag-soft); color: #5b21b6; border-color: #ddcefc; }

/* --------------------------------------------------------------------------
   Code blocks - Python indentation must survive exactly as authored
   -------------------------------------------------------------------------- */

.code {
    margin: .7rem 0;
    padding: .8rem .95rem;
    background: #10182b;
    color: #e6edf7;
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.code code {
    display: block;
    font-family: var(--mono);
    font-size: .88rem;
    line-height: 1.55;
    white-space: pre;
    tab-size: 4;
}

.code-light {
    background: var(--surface-alt);
    color: var(--text);
    border: 1px solid var(--border);
}

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

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

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

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

.table th {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
    background: var(--surface-alt);
}

.table tbody tr:hover { background: var(--surface-alt); }
.table tbody tr:last-child td { border-bottom: none; }

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

/* --------------------------------------------------------------------------
   Statistic tiles
   -------------------------------------------------------------------------- */

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

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .85rem 1rem;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    font-weight: 700;
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1.2;
    margin-top: .15rem;
}

.stat-note {
    font-size: .78rem;
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Pagination (Laravel default markup)
   -------------------------------------------------------------------------- */

.pagination-wrap {
    padding: .8rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: .85rem;
}


.pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .6rem;
}

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

.pager-links {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
}

.pager-link {
    display: inline-block;
    padding: .3rem .6rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: .84rem;
    font-variant-numeric: tabular-nums;
}

.pager-link:hover {
    background: var(--surface-alt);
    text-decoration: none;
}

.pager-link.is-current {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 650;
}

.pager-link.is-disabled {
    opacity: .45;
    cursor: not-allowed;
}

.pager-gap {
    padding: .3rem .3rem;
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Centred single-purpose screens (student login, name, instructions,
   administrator sign in)

   Shared by both sides of the application, so it lives here rather than in
   exam.css: the admin layout does not load exam.css.
   -------------------------------------------------------------------------- */

.screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.screen-card {
    width: 100%;
    max-width: 480px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 1.75rem;
}

.screen-card.wide { max-width: 700px; }

.screen-brand {
    text-align: center;
    margin-bottom: 1.4rem;
}

.screen-brand h1 {
    font-size: 1.3rem;
    margin-bottom: .2rem;
    color: var(--text);
}

.screen-brand p {
    color: var(--muted);
    font-size: .88rem;
    margin: 0;
}

/* --------------------------------------------------------------------------
   Print - result sheets
   -------------------------------------------------------------------------- */

@media print {
    body { background: #fff; }
    .no-print { display: none !important; }
    .card { box-shadow: none; }
}
