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

body {
    margin: 0;
    font-family: 'Segoe UI', sans-serif;
    background-color: #f4f6f9;
    color: #222;
}

/* Buttons */
.btn-primary {
    background-color: #1e3a5f;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover { background-color: #16304f; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background-color: #e2e8f0;
    color: #333;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover { background-color: #cbd5e1; }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background-color: #dc2626;
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-danger:hover { background-color: #b91c1c; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.85rem; }

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
}

.form-group label {
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    padding: 0.5rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 0.95rem;
    width: 100%;
    max-width: 400px;
}

.form-group select:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    cursor: not-allowed;
}

.field-note {
    font-size: 0.8rem;
    color: #94a3b8;
    font-style: italic;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

/* Password toggle */
.password-input-wrapper {
    display: flex;
    align-items: center;
    max-width: 400px;
    gap: 0;
}

.password-input-wrapper input {
    flex: 1;
    max-width: none;
    border-right: none;
    border-radius: 4px 0 0 4px;
}

.btn-toggle-password {
    padding: 0.5rem 0.75rem;
    background: #e2e8f0;
    border: 1px solid #cbd5e1;
    border-left: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    font-size: 0.85rem;
    color: #444;
    white-space: nowrap;
}

.btn-toggle-password:hover {
    background: #cbd5e1;
}

/* Alerts */
.alert-error {
    background-color: #fee2e2;
    color: #b91c1c;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Home / Login */
.home-container {
    max-width: 480px;
    margin: 4rem auto;
}

.welcome-section { text-align: center; margin-bottom: 2rem; }
.welcome-section h1 { color: #1e3a5f; }

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.login-card h2 { margin-top: 0; }

.login-card .btn-primary { width: 100%; text-align: center; }

/* Dashboard */
.dashboard-container { max-width: 800px; margin: 0 auto; }

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.empty-state { text-align: center; padding: 3rem; }
.empty-state-inline { color: #64748b; font-style: italic; }

.page-list { display: flex; flex-direction: column; gap: 1rem; }

.page-card {
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.page-card-title { font-weight: 600; font-size: 1.05rem; flex: 1; }
.page-card-date { color: #64748b; font-size: 0.85rem; }
.page-card-actions { display: flex; gap: 0.5rem; }

/* Editor */
.editor-container { max-width: 800px; margin: 0 auto; }

.editor-actions { display: flex; gap: 1rem; margin-top: 1rem; }

.page-preview {
    width: 100%;
    height: 400px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
}

/* Student viewer page */
.student-viewer-container { max-width: 800px; margin: 0 auto; }

.student-picker select {
    max-width: 500px;
}

.student-pages-section { margin-top: 1.5rem; }
.student-pages-section h2 { margin-bottom: 1rem; }

/* Viewer — full height, slim toolbar, bleeds to edges */
.viewer-wrap {
    margin: -2rem -1.5rem;
    overflow: hidden;
}

.viewer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    background: #1e3a5f;
    color: white;
}

.viewer-page-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.viewer-actions {
    display: flex;
    gap: 0.5rem;
}

.page-viewer-full {
    display: block;
    width: 100%;
    height: calc(100vh - 54px - 34px);
    border: none;
}

.viewer-loading {
    padding: 2rem;
}

/* Profile */
.profile-container { max-width: 600px; margin: 0 auto; }

.profile-card {
    display: flex;
    gap: 2rem;
    align-items: center;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.profile-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #1e3a5f;
}

.profile-image-placeholder {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #64748b;
    text-align: center;
}

/* Admin */
.admin-container { max-width: 960px; margin: 0 auto; }
.admin-section { margin-bottom: 2.5rem; }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.admin-table th {
    background-color: #1e3a5f;
    color: white;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.9rem;
}

.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9rem;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table td .btn-secondary,
.admin-table td .btn-danger { margin-right: 0.5rem; }

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.modal-wide {
    max-width: 700px;
}

.modal h3 { margin-top: 0; }
.modal-actions { display: flex; gap: 1rem; margin-top: 1rem; }

/* Blazor error UI */
#blazor-error-ui {
    background: #fee2e2;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss { cursor: pointer; }
