/* Global Styles & Variables */
:root {
    --primary: #0284c7;
    --primary-light: #e0f2fe;
    --primary-hover: #0369a1;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #475569;
    --text-light: #94a3b8;
    --border-color: #e2e8f0;
    --success: #10b981;
    --success-light: #ecfdf5;
    --error: #f43f5e;
    --error-light: #fff1f2;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    min-height: 100vh;
}

/* Background blob aesthetics */
body::before {
    content: "";
    position: fixed;
    top: -20%;
    left: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    bottom: -20%;
    right: -20%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.05) 0%, rgba(255, 255, 255, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

/* App Container Layout */
.app-container {
    width: 100%;
    max-width: 640px;
    display: flex;
    flex-direction: column;
    padding: 20px;
    min-height: 100vh;
}

/* Header Aesthetics */
.app-header {
    margin-bottom: 24px;
    padding: 12px 4px;
}

.logo-area {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.logo-icon {
    font-size: 24px;
    color: var(--primary);
}

.logo-area h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.02em;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    animation: pulse 1.6s infinite;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Card Styling */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}

.card-header-icon {
    width: 56px;
    height: 56px;
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 20px;
}

.card h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.card-desc {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* Form Styling */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.form-group label i {
    margin-right: 4px;
    color: var(--text-light);
}

.required {
    color: var(--error);
}

.optional {
    color: var(--text-light);
    font-weight: normal;
    font-size: 0.75rem;
}

.form-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-main);
    background-color: #ffffff;
    transition: var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Phase Selector Radio Cards */
.phase-selector {
    margin: 28px 0;
}

.selector-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.phase-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.phase-card {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.phase-card input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.phase-card:hover {
    border-color: var(--primary);
    background-color: var(--bg-main);
}

.phase-card.active {
    border-color: var(--primary);
    background-color: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
}

.phase-badge {
    align-self: flex-start;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
}

.badge-pre {
    background-color: #bae6fd;
    color: #0369a1;
}

.badge-post {
    background-color: #a7f3d0;
    color: #047857;
}

.phase-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.phase-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Button UI */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background-color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-secondary {
    background-color: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: #e2e8f0;
}

.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary-light);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 6px;
}

.btn-block {
    width: 100%;
}

/* Quiz Styles */
.quiz-header {
    margin-bottom: 24px;
}

.quiz-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    background-color: #e2e8f0;
    color: var(--text-muted);
}

.badge.pre {
    background-color: #bae6fd;
    color: #0369a1;
}

.badge.post {
    background-color: #a7f3d0;
    color: #047857;
}

.quiz-progress-text {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
}

.progress-bar-container {
    height: 6px;
    background-color: var(--border-color);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 10px;
    transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-container {
    margin-bottom: 28px;
}

.question-title {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.5;
    margin-bottom: 20px;
    color: var(--text-main);
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    width: 100%;
    padding: 16px 20px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: #ffffff;
    text-align: left;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: flex-start;
}

.option-btn:hover {
    border-color: var(--primary);
    background-color: var(--bg-main);
}

.option-btn.selected {
    border-color: var(--primary);
    background-color: var(--primary-light);
    box-shadow: 0 0 0 1px var(--primary);
    font-weight: 500;
}

/* Loading/AI Diagnosis Animation */
.text-center {
    text-align: center;
}

.ai-brain-animation {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 24px auto 32px auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brain-icon {
    font-size: 44px;
    color: var(--primary);
    z-index: 10;
}

.pulse-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--primary-light);
    opacity: 0.7;
    z-index: 1;
}

.pulse-1 { animation: pulseOutline 2s infinite linear; }
.pulse-2 { animation: pulseOutline 2s infinite linear; animation-delay: 0.6s; }
.pulse-3 { animation: pulseOutline 2s infinite linear; animation-delay: 1.2s; }

.loading-text {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

/* Skeleton Loading Animation */
.skeleton-loader {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px;
}

.skeleton-line {
    height: 12px;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: loadingSkeleton 1.5s infinite;
    border-radius: 4px;
    width: 100%;
}

.skeleton-line.short { width: 45%; }
.skeleton-line.medium { width: 75%; }

/* Results Banner */
.result-banner {
    display: flex;
    align-items: center;
    gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1.5px solid var(--border-color);
    margin-bottom: 28px;
}

.score-circle-outer {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: conic-gradient(var(--primary) calc(var(--score-pct) * 1%), var(--border-color) 0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.score-circle-inner {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background-color: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.score-number {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1;
}

.score-unit {
    font-size: 0.65rem;
    color: var(--text-light);
    font-weight: 700;
    text-transform: uppercase;
}

.result-summary-text h2 {
    margin-bottom: 4px;
    font-size: 1.35rem;
}

.result-summary-text p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* AI Advice Card & Print Styling */
.ai-report-card {
    background-color: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    margin-bottom: 28px;
}

.ai-report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 12px;
}

.ai-title-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spark-icon {
    color: #eab308;
    font-size: 18px;
}

.ai-report-header h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.ai-advice-markdown {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-main);
}

.ai-advice-markdown h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    margin-top: 14px;
    margin-bottom: 8px;
    color: var(--primary);
    border-left: 3px solid var(--primary);
    padding-left: 8px;
}

.ai-advice-markdown p {
    margin-bottom: 10px;
}

.ai-advice-markdown ul, .ai-advice-markdown ol {
    padding-left: 20px;
    margin-bottom: 14px;
}

.ai-advice-markdown li {
    margin-bottom: 6px;
}

/* Review Section */
.review-section {
    margin-bottom: 28px;
}

.review-section h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.review-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
    background-color: #ffffff;
    transition: var(--transition);
}

.review-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 8px;
}

.review-q-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.review-status-icon {
    font-size: 16px;
}

.review-card.correct {
    border-left: 4px solid var(--success);
}
.review-card.correct .review-status-icon {
    color: var(--success);
}

.review-card.incorrect {
    border-left: 4px solid var(--error);
}
.review-card.incorrect .review-status-icon {
    color: var(--error);
}

.review-details {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.review-row {
    margin-bottom: 4px;
}

.review-explanation {
    margin-top: 8px;
    padding: 8px 12px;
    background-color: var(--bg-main);
    border-radius: 4px;
    font-size: 0.78rem;
    border-left: 2px solid var(--text-light);
}

/* Footer Styling */
.app-footer {
    margin-top: auto;
    padding: 24px 0 12px 0;
    font-size: 0.75rem;
    color: var(--text-light);
    border-top: 1px solid var(--border-color);
}

.admin-link-area {
    margin-top: 8px;
}

.admin-link-area a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.admin-link-area a:hover {
    text-decoration: underline;
}

/* Helper Utilities */
.hidden {
    display: none !important;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

@keyframes pulseOutline {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

@keyframes loadingSkeleton {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Responsive Styles */
@media (max-width: 480px) {
    .app-container {
        padding: 12px;
    }
    .card {
        padding: 20px;
        border-radius: var(--radius-md);
    }
    .result-banner {
        flex-direction: column;
        text-align: center;
        gap: 16px;
    }
    .btn {
        padding: 12px 20px;
    }
}

/* Print Styling */
@media print {
    body {
        background: white;
        color: black;
    }
    .app-header, .app-footer, .result-footer, #btn-print, .review-section {
        display: none !important;
    }
    .app-container {
        max-width: 100%;
        padding: 0;
    }
    .card {
        border: none;
        box-shadow: none;
        padding: 0;
    }
    .result-banner {
        border-bottom: 2px solid black;
    }
    .ai-report-card {
        border: 1px solid black;
        background: white;
    }
}
