/* K12Edu — Clean minimal styling */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    line-height: 1.6;
}

.page-wrapper {
    display: flex;
    justify-content: center;
    padding: 40px 16px;
    min-height: 100vh;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    padding: 32px;
    width: 100%;
    max-width: 1000px;
}

/* Header / top bar */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.top-left {
    display: flex;
    align-items: center;
}

.top-right {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}

.logo-wrapper {
    text-align: center;
    margin-bottom: 8px;
}

.logo-text {
    font-size: 28px;
    font-weight: 700;
    color: #2563eb;
    text-decoration: none;
}

.email {
    color: #666;
}

.logout-form {
    display: inline;
}

.btn-logout {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 12px;
    cursor: pointer;
    font-size: 13px;
    color: #666;
}

.btn-logout:hover {
    background: #f5f5f5;
}

/* Divider */
.divider {
    border-top: 1px solid #eee;
    margin: 16px 0;
}

/* Typography */
h1 {
    font-size: 22px;
    margin-bottom: 20px;
    color: #1a1a1a;
}

h2 {
    font-size: 18px;
    margin: 12px 0;
    color: #1f2937;
}

.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.header-action {
    display: flex;
    align-items: center;
    gap: 10px;
}

.subtitle {
    color: #6b7280;
    font-size: 13px;
    margin-top: 4px;
}

.page-title {
    margin: 0;
}

.row-title {
    margin: 0;
    min-width: 140px;
}

.row-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.tabs-shell {
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    align-items: flex-end;
}

.tab-radio {
    display: none;
}

.tab-pill {
    padding: 8px 14px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    font-size: 13px;
    cursor: pointer;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 36px;
}

.tab-radio:checked + .tab-pill {
    background: #111827;
    color: #fff;
    border-color: #111827;
}

.tab-panel {
    display: none;
    width: 100%;
    margin-top: 6px;
    order: 2;
}

.tab-radio:checked + .tab-pill + .tab-panel {
    display: block;
}

.tab-radio:checked + .tab-pill + .tab-panel {
    display: block;
}

.section-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    background: #fafafa;
}

.section-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.section-title {
    font-weight: 600;
    color: #111827;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.grade-block {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #e5e7eb;
}

.grade-accordion,
.term-accordion {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-top: 10px;
    background: #fff;
    padding: 8px 12px;
}

.grade-summary,
.term-summary {
    cursor: pointer;
    font-weight: 600;
    color: #111827;
    list-style: none;
}

.grade-summary::-webkit-details-marker,
.term-summary::-webkit-details-marker {
    display: none;
}

.grade-actions {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.term-block {
    margin-top: 10px;
    padding: 10px 0;
    border-top: 1px solid #e5e7eb;
}

.term-row {
    display: grid;
    grid-template-columns: auto 120px 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-top: 1px solid #e5e7eb;
}

.term-title {
    font-weight: 600;
    color: #111827;
}

.term-meta {
    font-size: 12px;
    color: #6b7280;
}

.term-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.term-toolbar {
    margin-top: 10px;
}

.term-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

.term-table th,
.term-table td {
    border: 1px solid #e5e7eb;
    padding: 8px 10px;
}

.term-table th {
    background: #f8fafc;
    text-align: left;
    font-weight: 600;
}

.action-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.subtitle {
    font-size: 16px;
    font-weight: 400;
    color: #666;
}

.cn {
    color: #888;
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="file"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 8px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-error {
    color: #dc2626;
    font-size: 13px;
    margin-top: 4px;
}

.form-error ul {
    list-style: none;
    padding: 0;
}

.help-text {
    display: block;
    color: #888;
    font-size: 13px;
    margin-top: 4px;
}

/* Radio */
.inline-radio {
    display: flex;
    gap: 20px;
    margin-top: 4px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
}

/* Checkbox */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #1d4ed8;
}

.btn-secondary {
    display: inline-block;
    background: #f3f4f6;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 15px;
    cursor: pointer;
    text-decoration: none;
    margin-left: 8px;
}

.btn-secondary:hover {
    background: #e5e7eb;
}

.input-inline {
    height: 40px;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    margin-right: 8px;
}

.indent-1 { margin-left: 16px; }
.indent-2 { margin-left: 32px; }
.indent-3 { margin-left: 48px; }

.btn-secondary:disabled {
    background: #f3f4f6;
    color: #9ca3af;
    border-color: #e5e7eb;
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-link {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Footer links */
.footer-links {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
}

.footer-links a {
    color: #2563eb;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* Footer bar */
.footer-bar {
    text-align: center;
    font-size: 13px;
    color: #999;
}

/* Messages */
.messages {
    margin-bottom: 12px;
}

.message {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 6px;
}

.message.success {
    background: #dcfce7;
    color: #166534;
}

.message.error {
    background: #fee2e2;
    color: #991b1b;
}

.success-message {
    color: #16a34a;
    text-align: center;
    margin-top: 12px;
}

/* Info / error boxes */
.info-box {
    background: #dbeafe;
    border: 1px solid #3b82f6;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    color: #1e40af;
}

.error-box {
    background: #fee2e2;
    border: 1px solid #f87171;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    color: #991b1b;
}

/* Actions bar */
.actions {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

/* Report table */
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.report-table th,
.report-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.report-table th {
    font-weight: 600;
    color: #666;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-table {
    margin-top: 18px;
}

.info-table .report-table th {
    text-transform: none;
    font-size: 12px;
    width: 180px;
}

.report-table tbody tr:hover {
    background: #f9fafb;
}

.text-muted {
    color: #999;
    font-size: 13px;
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-processing {
    background: #dbeafe;
    color: #1e40af;
}

.badge-extracting,
.badge-translating,
.badge-summarizing {
    background: #dbeafe;
    color: #1e40af;
}

.badge-completed {
    background: #dcfce7;
    color: #166534;
}

.badge-failed {
    background: #fee2e2;
    color: #991b1b;
}

/* Empty state */
.empty-state {
    text-align: center;
    color: #999;
    padding: 40px 0;
    font-size: 15px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.tab {
    padding: 10px 20px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover {
    color: #2563eb;
}

.tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-content {
    min-height: 200px;
}

.result-text {
    font-size: 15px;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Markdown tables */
.result-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.result-text th,
.result-text td {
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    vertical-align: top;
}

.result-text th {
    background: #f3f4f6;
    font-weight: 600;
}

.result-text table td:first-child,
.result-text table th:first-child {
    width: 45%;
}

.result-text table td:not(:first-child),
.result-text table th:not(:first-child) {
    text-align: center;
    width: 13.75%;
}

.meta {
    font-size: 14px;
    color: #888;
    margin-bottom: 20px;
}

/* PDF embed */
.pdf-embed {
    margin-top: 24px;
}

.pdf-embed iframe {
    border: 1px solid #ddd;
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 600px) {
    .card {
        padding: 20px 16px;
    }

    .top-bar {
        flex-direction: column;
        gap: 8px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .report-table {
        font-size: 13px;
    }

    .report-table th,
    .report-table td {
        padding: 8px 6px;
    }
}
