/* ============================================================
   Oak-Ed – Web Awesome base styles
   ============================================================ */

html, body {
    min-height: 100%;
    padding: 0;
    margin: 0;
}

/* wa-page banner — logo strip above the header */
.site-banner {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.5rem;
    font-size: 0.8125rem;
}
.site-banner-logo {
    height: 52px;
    width: auto;
}

/* Header layout: brand left, user dropdown right */
.site-header {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 3.25rem;
    padding: 0.5rem 1.5rem;
}
.site-header__top {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.site-header__user {
    flex-shrink: 0;
    margin-left: auto;
}
.site-header .brand {
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
}

/* Sidebar width — only reserve a column on desktop; on mobile the nav is a drawer */
wa-page {
    --menu-width: 200px;
}
wa-page[view="mobile"] {
    --menu-width: 0;
}

/* Main layout */
.page-main {
    padding: 2rem 1.5rem;
    max-width: 1280px;
    margin: 0 auto;
}

/* Page header row */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h1,
.page-header h2 {
    margin: 0;
}

/* Small uppercase heading used at the top of stat / chart cards */
.card-heading {
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

/* Grid layouts */
.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}
.grid-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}
.centered {
    max-width: 900px;
    margin: 0 auto;
}
.centered-sm {
    max-width: 560px;
    margin: 0 auto;
}

/* Content cards */
.content-card {
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.content-card-light {
    border-radius: 0.5rem;
    padding: 1rem;
}
.content-card-flush {
    padding: 0;
    overflow: hidden;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th {
    text-align: left;
    padding: 0.625rem 0.875rem;
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.data-table td {
    padding: 0.75rem 0.875rem;
    vertical-align: middle;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Form fields (for Django-rendered native inputs) */
.form-field {
    margin-bottom: 1rem;
}
.form-field > label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.3rem;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="number"],
.form-field input[type="password"],
.form-field input[type="url"],
.form-field select,
.form-field textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    box-sizing: border-box;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-field select[multiple] {
    height: auto;
    padding: 0.25rem;
}
.form-field select[multiple] option {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
}
.form-field input[type="checkbox"],
.filterable-checkbox-list input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid var(--wa-color-neutral-400, #9ca3af);
    border-radius: 0.25rem;
    background: #fff;
    cursor: pointer;
    vertical-align: middle;
    margin-right: 0.375rem;
    flex-shrink: 0;
}
.form-field input[type="checkbox"]:focus-visible,
.filterable-checkbox-list input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--wa-color-brand-600, #3b82f6);
    outline-offset: 2px;
}
.form-field input[type="checkbox"]:checked,
.filterable-checkbox-list input[type="checkbox"]:checked {
    background-color: var(--wa-color-brand-600, #3b82f6);
    border-color: var(--wa-color-brand-600, #3b82f6);
}
.field-error {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}
.field-help {
    font-size: 0.8125rem;
    margin-top: 0.25rem;
}

/* Input with addon button (e.g. ISBN + Fetch) */
.input-addon {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
}
.input-addon > *:first-child {
    flex: 1;
}

/* Badge lists */
.badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

/* Button rows */
.button-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0;
    font-size: 0.875rem;
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
}
.breadcrumb li {
    display: flex;
    align-items: center;
}
.breadcrumb li + li::before {
    content: '/';
    margin: 0 0.5rem;
}
.breadcrumb a {
    text-decoration: none;
}
.breadcrumb a:hover {
    text-decoration: underline;
}
.breadcrumb .active a {
    pointer-events: none;
}

/* Meta info flex row (title + date) */
.meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

/* htmx indicator */
.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* Dialogs */
wa-dialog {
    --width: 520px;
}

/* Text helpers */
.text-muted {
    font-size: 0.875rem;
}
.text-sm  { font-size: 0.875rem; }
.text-xs  { font-size: 0.75rem; }
.text-base { font-size: 1rem; }
.text-lg  { font-size: 1.1rem; }
.text-center { text-align: center; }

/* Spacing */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }

/* Layout */
.w-full  { width: 100%; }
.hidden  { display: none; }
.grid-2  { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.font-mono { font-family: monospace; font-size: 0.85rem; }

/* Empty table / list state */
.empty-state {
    text-align: center;
    padding: 2rem;
}

/* Prose / markdown-rendered content */
.content { line-height: 1.7; }
.content p { margin: 0 0 0.875rem; }
.content p:last-child { margin-bottom: 0; }
.content h1, .content h2, .content h3,
.content h4, .content h5, .content h6 {
    font-weight: 600;
    line-height: 1.3;
    margin: 1.5rem 0 0.5rem;
}
.content h1 { font-size: 1.75rem; }
.content h2 { font-size: 1.4rem; }
.content h3 { font-size: 1.15rem; }
.content ul, .content ol { padding-left: 1.5rem; margin: 0 0 0.875rem; }
.content li { margin-bottom: 0.25rem; }
.content code {
    font-family: monospace;
    font-size: 0.875em;
    padding: 0.1em 0.35em;
    border-radius: 0.25rem;
}
.content pre {
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    font-size: 0.875rem;
    margin: 0 0 0.875rem;
}
.content blockquote {
    margin: 0 0 0.875rem;
    padding: 0.25rem 0 0.25rem 1rem;
}
.content a {
    text-decoration: none;
}
.content a:hover { text-decoration: underline; }
.content hr {
    border: none;
    margin: 1.25rem 0;
}
.content strong { font-weight: 600; }

/* Subtitle style */
.page-subtitle {
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

/* ============================================================
   Sidebar navigation (wa-page navigation slot)
   ============================================================ */

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    padding: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    min-height: 44px;
    border-radius: var(--wa-border-radius-medium, 0.375rem);
    color: var(--wa-color-neutral-700, #374151);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;
}

.nav-link:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--wa-color-neutral-900, #111);
    text-decoration: none;
}

.nav-link.active {
    background-color: var(--wa-color-brand-100, #dcfce7);
    color: var(--wa-color-brand-700, #15803d);
    font-weight: 600;
}

.nav-link wa-icon {
    font-size: 0.875rem;
    width: 1rem;
    flex-shrink: 0;
}

.data-table tbody tr {
    transition: background-color 0.1s;
}
.data-table tbody tr:hover {
    background-color: var(--wa-color-neutral-90, #f9fafb);
}

/* ============================================================
   Responsive (desktop-first: max-width overrides)
   ============================================================ */

/* Table scroll wrapper — always active so overflow:hidden on the card never clips content */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* 768px — grids collapse, header tightens */
@media (max-width: 768px) {
    .grid-3, .grid-2-1, .grid-2 { grid-template-columns: 1fr; }
    .site-header { padding: 0.375rem 0.75rem; }
    .site-banner-logo { height: 40px; }
    .page-main { padding: 1.5rem 1rem; }
}

/* 480px — phone portrait adjustments */
@media (max-width: 480px) {
    .page-main { padding: 1rem 0.75rem; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    wa-dialog { --width: min(520px, calc(100vw - 2rem)); }
}

/* Dashboard overdue alert.
   Intentionally uses explicit hex rather than the --wa-color-danger-* theme
   tokens: that palette's danger shade rendered as a saturated block that was
   too harsh here, so these soft red values were chosen deliberately for a
   calmer alert. */
.dashboard-overdue {
    margin-bottom: 1.5rem;
    border-left: 4px solid #ef4444;
    background: #fef2f2;
}

.dashboard-overdue__heading {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.625rem;
    color: #991b1b;
}

.dashboard-overdue__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0;
    border-bottom: 1px solid #fecaca;
}

.dashboard-overdue__row:last-child {
    border-bottom: none;
}

.dashboard-overdue__learner {
    font-weight: 500;
    font-size: 0.875rem;
}

.dashboard-overdue__link {
    font-size: 0.875rem;
    font-weight: 600;
    color: #b91c1c;
    text-decoration: none;
    white-space: nowrap;
}

/* Filterable checkbox tag selector */
.filterable-checkbox-list {
    border: 1px solid var(--wa-color-neutral-200, #e5e7eb);
    border-radius: 0.375rem;
    padding: 0.5rem;
}

.filterable-checkbox-search {
    width: 100%;
    margin-bottom: 0.5rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--wa-color-neutral-300, #d1d5db);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    box-sizing: border-box;
}

.filterable-checkbox-list .checkbox-scroll {
    max-height: 180px;
    overflow-y: auto;
}

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