/* =====================================================
   TrainingApp — Mobile-First Styles
   ===================================================== */

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

html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background: #f4f6f9;
    color: #333;
}

h1:focus { outline: none; }

a, .btn-link { color: #1b6ec2; }

/* ---- Layout ---- */
.ta-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.ta-header {
    background: #1b6ec2;
    color: #fff;
    padding: 0.9rem 1.2rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ta-header-brand {
    font-size: 1.2rem;
    color: #fff;
    text-decoration: none;
}

.ta-header-nav {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.ta-nav-link {
    color: #cce4ff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.15s;
}

.ta-nav-link:hover {
    color: #fff;
    text-decoration: underline;
}

.ta-main {
    flex: 1;
    padding: 1rem;
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

/* ---- Home Page ---- */
.home-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
}

.home-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    width: 100%;
}

.home-card h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.home-example code {
    background: #f0f4f8;
    padding: 0.2em 0.5em;
    border-radius: 4px;
    font-size: 0.95rem;
}

/* ---- Training Page ---- */
.training-page { padding-bottom: 2rem; }

.training-header {
    background: #fff;
    border-radius: 10px;
    padding: 1.2rem 1.4rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.training-header h1 { font-size: 1.4rem; margin: 0 0 0.3rem; }
.training-description { color: #555; margin: 0; font-size: 0.95rem; }

.training-header-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn-copy-link {
    flex-shrink: 0;
    background: none;
    border: 1px solid #1b6ec2;
    color: #1b6ec2;
    border-radius: 6px;
    padding: 0.25rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.btn-copy-link:hover {
    background: #1b6ec2;
    color: #fff;
}

/* ---- Progress Bar ---- */
.progress-bar-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.progress-bar-track {
    flex: 1;
    height: 10px;
    background: #dde3ea;
    border-radius: 99px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: #1b6ec2;
    border-radius: 99px;
    transition: width 0.3s ease;
}

.progress-label { font-size: 0.8rem; color: #666; white-space: nowrap; }

/* ---- Step Container ---- */
.step-container {
    background: #fff;
    border-radius: 10px;
    padding: 1.4rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
    margin-bottom: 1rem;
}

.step-title { font-size: 1.2rem; margin: 0 0 1rem; color: #1b6ec2; }

/* video */
.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.video-wrapper iframe {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* pdf */
.pdf-wrapper { display: flex; flex-direction: column; gap: 0.75rem; }

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

.pdf-embed {
    width: 100%;
    height: 480px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
}

/* fullscreen */
.media-fullscreen-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.btn-fullscreen {
    align-self: flex-end;
    background: none;
    border: 1px solid #1b6ec2;
    color: #1b6ec2;
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btn-fullscreen:hover {
    background: #1b6ec2;
    color: #fff;
}

/* ---- Media Overlay (mobile fullscreen fallback) ---- */
.media-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #000;
    display: flex;
    flex-direction: column;
}

.media-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    background: #1a1a1a;
    flex-shrink: 0;
}

.media-overlay-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-overlay-close {
    background: none;
    border: 1px solid #888;
    color: #fff;
    border-radius: 6px;
    padding: 0.3rem 0.8rem;
    font-size: 0.9rem;
    cursor: pointer;
    flex-shrink: 0;
}

.media-overlay-close:hover {
    background: #fff;
    color: #000;
}

.media-overlay-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.media-overlay-body iframe {
    width: 100%;
    height: 100%;
    border: none;
    flex: 1;
}

.media-overlay-video {
    position: relative;
    width: 100%;
    height: 100%;
}

.media-overlay-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* text */
.text-content { line-height: 1.7; font-size: 1rem; }
.text-content ul { padding-left: 1.4rem; }
.text-content li { margin-bottom: 0.4rem; }

/* ---- Step Navigation ---- */
.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.step-nav .btn { flex: 1; padding: 0.75rem 1rem; font-size: 1rem; }

/* ---- Quiz ---- */
.quiz-component {
    background: #fff;
    border-radius: 10px;
    padding: 1.4rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.quiz-title { font-size: 1.3rem; margin: 0 0 0.25rem; }
.quiz-subtitle { color: #666; font-size: 0.9rem; margin-bottom: 1.2rem; }

.quiz-question { margin-bottom: 1.5rem; }
.question-text { margin-bottom: 0.6rem; font-size: 1rem; }

.option-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 2px solid #dde3ea;
    border-radius: 8px;
    background: #fff;
    text-align: left;
    font-size: 0.95rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.option-btn:hover { border-color: #1b6ec2; background: #f0f6ff; }
.option-btn.selected { border-color: #1b6ec2; background: #dceeff; font-weight: 600; }

.quiz-validation { color: #c0392b; font-size: 0.9rem; margin-top: 0.5rem; }

.btn-block { display: block; width: 100%; }

/* ---- Completion Form ---- */
.completion-form {
    background: #fff;
    border-radius: 10px;
    padding: 1.6rem;
    box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.completion-form h2 { margin-top: 0; }
.form-label { font-weight: 600; }
.form-control { font-size: 1rem; }

/* ---- Completion Page ---- */
.completion-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 2rem;
}

.result-card {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
    width: 100%;
}

.result-card.pass { border-top: 6px solid #27ae60; }
.result-card.fail { border-top: 6px solid #e74c3c; }

.result-icon { font-size: 3.5rem; margin-bottom: 0.5rem; }
.result-card h1 { font-size: 1.6rem; margin: 0.25rem 0; }
.result-training { font-size: 1rem; color: #555; }
.result-score { font-size: 1.2rem; margin: 0.5rem 0; }
.cert-note { color: #555; font-size: 0.9rem; }

.btn-cert {
    display: inline-block;
    background: #27ae60;
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    padding: 0.65rem 1.5rem;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}
.btn-cert:hover { background: #1e8449; color: #fff; text-decoration: none; }

/* ---- Loading / Error States ---- */
.loading-state, .error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #555;
}

/* ---- Bootstrap overrides ---- */
.btn { border-radius: 8px; font-size: 1rem; }
.btn-primary { background-color: #1b6ec2; border-color: #1861ac; }
.btn-primary:hover { background-color: #1558a0; }
.btn-success { background-color: #27ae60; border-color: #219a52; }
.btn-outline-primary { color: #1b6ec2; border-color: #1b6ec2; }
.btn-outline-secondary { color: #555; border-color: #aaa; }
.mt-3 { margin-top: 1rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.w-100 { width: 100% !important; }

/* ---- Blazor error UI ---- */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,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;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ---- Loading progress (Blazor WASM) ---- */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ---- Responsive breakpoints ---- */
@media (min-width: 600px) {
    .ta-main { padding: 1.5rem; }
    .step-nav .btn { flex: none; min-width: 140px; }
    .quiz-component, .completion-form, .step-container { padding: 2rem; }
}

/* =====================================================
   Training Builder & Admin Styles
   ===================================================== */

.builder-page { padding-bottom: 4rem; }

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.builder-header h1 { margin: 0; font-size: 1.5rem; }
.builder-subtitle { color: #555; margin: 0.2rem 0 0; font-size: 0.9rem; }
.builder-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.builder-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.75rem 1.75rem 1.25rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    margin-bottom: 2rem;
    border-top: 4px solid #1b6ec2;
}

.builder-section.section-steps { border-top-color: #2e86ab; }
.builder-section.section-quiz  { border-top-color: #7b2d8b; }

.section-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eaecf0;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 1rem;
    color: #1b6ec2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.section-title .section-icon { font-size: 1.1rem; }
.section-header-row .section-title { margin: 0; }
.section-count {
    font-size: 0.8rem;
    color: #fff;
    background: #1b6ec2;
    border-radius: 20px;
    padding: 0.15rem 0.65rem;
    font-weight: 600;
}
.section-steps .section-count { background: #2e86ab; }
.section-quiz  .section-count { background: #7b2d8b; }

.form-row { margin-bottom: 1rem; }
.form-row-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}
@media (max-width: 600px) {
    .form-row-group { grid-template-columns: 1fr; }
}
.form-label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.3rem; }
.form-hint { display: block; color: #888; font-size: 0.8rem; margin-top: 0.2rem; }
.required { color: #c0392b; }
.id-row { display: flex; flex-direction: column; gap: 0.25rem; }
.id-row code { font-size: 0.85rem; color: #1b6ec2; }
.textarea-content { font-family: monospace; font-size: 0.88rem; }

.step-editor {
    border: 1px solid #d0dce8;
    border-left: 4px solid #2e86ab;
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
    background: #f7fbff;
    box-shadow: 0 1px 4px rgba(46,134,171,0.07);
}

.quiz-editor {
    border: 1px solid #ddd0e8;
    border-left: 4px solid #7b2d8b;
    border-radius: 8px;
    padding: 1.1rem 1.2rem;
    margin-bottom: 1rem;
    background: #fdf7ff;
    box-shadow: 0 1px 4px rgba(123,45,139,0.07);
}

.step-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid #e0eaf2;
}

.quiz-editor .step-editor-header {
    border-bottom-color: #ead8f0;
}

.step-number {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 700;
    font-size: 0.82rem;
    color: #fff;
    background: #2e86ab;
    border-radius: 20px;
    padding: 0.2rem 0.75rem;
    letter-spacing: 0.4px;
    text-transform: uppercase;
}

.quiz-editor .step-number {
    background: #7b2d8b;
}

.step-editor-actions { display: flex; gap: 0.3rem; }

.btn-icon {
    background: none;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
    cursor: pointer;
    line-height: 1.4;
    transition: background 0.15s;
}

.btn-icon:hover:not(:disabled) { background: #f0f0f0; }
.btn-icon:disabled { opacity: 0.35; cursor: default; }
.btn-icon.danger { border-color: #e74c3c; color: #e74c3c; }
.btn-icon.danger:hover { background: #fdf0ee; }

.option-editor-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
}

.option-editor-row input[type=radio] { flex-shrink: 0; width: 1.1rem; height: 1.1rem; cursor: pointer; }
.option-editor-row .form-control { flex: 1; }

.preview-block {
    border: 1px dashed #c0cfe0;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-top: 0.5rem;
    background: #f7faff;
    font-size: 0.9rem;
}

.preview-block summary { cursor: pointer; color: #1b6ec2; font-size: 0.85rem; font-weight: 600; }
.preview-content { padding-top: 0.5rem; line-height: 1.6; }

.add-buttons { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }

.builder-bottom-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    border-top: 1px solid #dde3ea;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin: 0 -1rem -4rem;
    z-index: 10;
}

.alert {
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.alert-danger { background: #fdf0ee; border: 1px solid #f5c6cb; color: #721c24; }
.alert-success { background: #eafaf1; border: 1px solid #b7dfca; color: #155724; }

.admin-page { padding-bottom: 2rem; }
.admin-table-wrapper { overflow-x: auto; border-radius: 10px; box-shadow: 0 1px 6px rgba(0,0,0,0.07); }

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 0.9rem;
}

.admin-table th {
    background: #f4f6f9;
    padding: 0.7rem 1rem;
    text-align: left;
    font-weight: 700;
    border-bottom: 2px solid #dde3ea;
}

.admin-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid #eef0f3;
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #f9fafb; }
.text-center { text-align: center; }
.text-muted { color: #888; font-size: 0.82rem; }

.action-buttons { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.badge-sample { display: inline-block; font-size: 0.7rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 999px; background: #e8f4fd; color: #1a73e8; border: 1px solid #b3d4f7; vertical-align: middle; }
.import-label { cursor: pointer; margin: 0; }
.form-field { display: flex; flex-direction: column; gap: 0.25rem; }
.form-field label { font-size: 0.85rem; font-weight: 600; color: #444; }
.form-control { padding: 0.45rem 0.65rem; border: 1px solid #d0d7e0; border-radius: 6px; font-size: 0.95rem; width: 100%; box-sizing: border-box; }
.form-control:focus { outline: none; border-color: #4a90e2; box-shadow: 0 0 0 2px rgba(74,144,226,0.15); }
.mt-2 { margin-top: 0.5rem; }
.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.btn-outline-danger { color: #e74c3c; border-color: #e74c3c; background: none; }
.btn-outline-danger:hover { background: #fdf0ee; }
.btn-danger { background: #e74c3c; border-color: #c0392b; color: #fff; }
.btn-danger:hover { background: #c0392b; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.modal-box {
    background: #fff;
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 1.5rem; }

.empty-state {
    text-align: center;
    padding: 2rem;
    color: #888;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px dashed #d0d7e0;
}

.home-divider { margin: 1.5rem 0; border-color: #eee; }
.home-admin-note { color: #666; font-size: 0.9rem; margin-bottom: 0.5rem; }
.home-sample-row { display: flex; align-items: center; justify-content: center; gap: 0.75rem; margin-top: 1rem; flex-wrap: wrap; }
.home-sample-label { color: #666; font-size: 0.9rem; }

/* ---- Course Catalog ---- */
.catalog-page { padding-bottom: 2rem; }

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

.catalog-header h1 { font-size: 1.6rem; margin: 0 0 0.25rem; }
.catalog-subtitle { margin: 0; color: #555; font-size: 0.95rem; }

.catalog-search-bar { margin-bottom: 1.25rem; }

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.course-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 6px rgba(0,0,0,0.08);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    cursor: pointer;
    transition: box-shadow 0.15s, transform 0.15s;
    border: 1px solid transparent;
}

.course-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    transform: translateY(-2px);
    border-color: #c3d9f5;
}

.course-card-icon { font-size: 1.75rem; line-height: 1; }

.course-card-body { flex: 1; }

.course-card-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.3rem;
    color: #1a1a2e;
}

.course-card-description {
    font-size: 0.88rem;
    color: #555;
    margin: 0;
    line-height: 1.5;
}

.course-card-footer {
    border-top: 1px solid #eef0f3;
    padding-top: 0.6rem;
    margin-top: 0.25rem;
}

.course-card-start {
    font-size: 0.85rem;
    font-weight: 600;
    color: #1b6ec2;
}
