:root {
    --primary: steelblue;
    --bg: silver;
    --text: #264653;
    --white: #ffffff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

@font-face {
    font-family: "myemoji";

    src: local('Apple Color Emoji'),
         local('Android Emoji'),
         local('Segoe UI Emoji'),
         local('Noto Color Emoji'),
         local(EmojiSymbols),
         local(Symbola);

    unicode-range: U+1F600-1F64F;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-height: 100svh;
    max-height: 100svh;
}

#app {
    width: 100%;
    max-width: 500px; /* Keeps it looking like a phone on desktop */
    min-height: 100%;
    max-height: 100%;
    position: relative;
    padding-bottom: 70px; /* Space for bottom nav */
}

.view {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    height: 100%;
    /* height: calc(100vh - 120px); */
    padding: 15px;
    animation: fadeIn 0.3s ease;
}

.hidden { display: none !important; }

.invisible { visibility: hidden; }

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

/* Cards & Forms */
.card {
    background: whitesmoke;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 4px 4px 6px rgba(0,0,0,0.3);
    /* margin-bottom: 10px; */
    min-height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

h1, h2 { margin-bottom: 12px; text-align: center; }

.input-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: 400; }

input {
    width: 100%;
    padding: 12px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom on focus */
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    margin-top: 10px;
}

/* Bottom Navigation */
#bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100svw;
    max-width: 500px;
    height: 65px;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    align-items: center;
    border-top: 1px solid #ddd;
    padding-bottom: env(safe-area-inset-bottom); /* For iPhone notch */
}

.nav-item {
    background: none;
    border-bottom: 4px solid transparent;
    border-top: 4px solid transparent;
    border-left: none;
    border-right: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    width: 100%;
    height: 100%;
    font-weight: bold;
}

.nav-item.active { 
    /* background-color: #f0f0f0;  */
    border-bottom-color: steelblue;
    /* border-top-color: steelblue; */
    /* color: floralwhite; */
}

.nav-item span { font-size: 24px; }

/* Container to center the spinner on the screen */
#loading-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh; /* Full viewport height */
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    background-color: white; /* Matches your app background */
    z-index: 9999;
}

/* The actual spinner element */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3; /* Light grey background circle */
    border-top: 5px solid #3498db; /* Blue color for the moving part */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* The rotation animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Container to hold all toasts */
#toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* The actual toast style */
.toast {
    min-width: 250px;
    margin-top: 10px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-family: sans-serif;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    
    /* Animation properties */
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s ease;
}

/* Success color */
.toast-success {
    background-color: #2ecc71;
}

/* Error color (optional, if you want to use it for failures) */
.toast-error {
    background-color: #e74c3c;
}

/* Class to trigger when the toast is visible */
.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* Class to trigger the fade-out animation before removal */
.toast.fade-out {
    opacity: 0;
    transform: translateY(-20px);
}

form#quiz-start-form {
    min-width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    flex-grow: 1;
}

form#exam-start-form {
    min-width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    flex-grow: 1;
}

div#question {
    min-height: 100%;
    max-height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

div#question-container {
    /* min-height: 100px; */
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: left;
    font-size: 1.1rem;
    margin-top: auto;
    margin-bottom: auto;
}

div#question-container img {
    max-width: 120px;
    max-height: 160px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

div#exam-question-container {
    /* min-height: 100px; */
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: left;
    font-size: 1.1rem;
    margin-top: auto;
    margin-bottom: auto;
}

div#exam-question-container img {
    max-width: 120px;
    max-height: 160px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

div#choice-container {
    text-align: left;
    width: 100%;
    /* margin-top: auto; */
}

div#choice-container img {
    max-width: 200px;
    max-height: 50px;
    display: block;
}

div#exam-choice-container {
    text-align: left;
    width: 100%;
    /* margin-top: auto; */
}

div#exam-choice-container img {
    max-width: 200px;
    max-height: 50px;
    display: block;
}

.form-group {
    margin-bottom: 8px;
}

label.main-label {
    display: block;
    font-weight: 600;
    /* margin-bottom: 10px; */
    color: #34495e;
}

/* Slider Styling */
.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
}

input[type="range"] {
    flex-grow: 1;
    cursor: pointer;
}

.slider-value {
    font-weight: bold;
    color: #3498db;
    font-size: 1.2rem;
    min-width: 40px;
}

/* div.justified {
    display: flex;
    justify-content: space-between;
} */

/* Checkbox Grid Styling */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* 2 columns for mobile */
    gap: 10px;
    padding-top: 10px;
}

/* Hide default radio button appearance */
input[type="radio"] {
    display: none;
    opacity: 0;
    position: absolute;
}

/* Style for selected radio button */
input[type="radio"]:checked + .option-item {
    /* Adjust this color as needed */
    /* background: gainsboro; */
    border: 2px solid #3498db;
    /* transform: translate(2px, 2px); */
    box-shadow: 2px 2px 6px rgba(0,0,0,0.3);
}

.option-item {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    background: ghostwhite;
    box-shadow: 4px 4px 6px rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid gainsboro;
    font-size: 0.75rem;
}

.option-item:active {
    background: #e2e6ea;
}

.option-item input {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

#next-btn, #confirm-btn {
    display: block;
}

#study-result-card .btn {
    display: block;
    margin: 10px 0px;
}

.btn {
    margin-top: 10px;
    padding: 10px;
    display: none;
    cursor: pointer;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0percent 0.3s;
    width: 100%;
}

.btn:active {
    transform: scale(0.98);
}
/* Confirm Button */
.btn-submit {
    display: block;
    margin-top: auto;
    padding: 15px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0percent 0.3s;
    width: 100%;
}

.btn-submit:hover {
    background-color: #2980b9;
}

.btn-submit:active {
    transform: scale(0.98);
}

.exam-btn {
    display: block;
    width: 5rem;
    margin-top: auto;
    padding: 6px 10px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0percent 0.3s;
}

.option-btn.selected {
    border: 2px solid var(--primary);
    background-color: lavender;
}

.option-btn {
    display: block;
    width: 100%;
    margin: 10px 0;
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    transition: 0.3s;
    font-size: 0.95rem;
    text-align: left;
    background-color: whitesmoke;
}

.option-btn:hover {
    background-color: #e0e0e0;
}

.correct {
    background-color: #d4edda !important;
    color: #155724;
    border-color: #c3e6cb;
}

.incorrect {
    background-color: #f8d7da !important;
    color: #721c24;
    border-color: #f5c6cb;
}

span.underline {
    display: inline-block;
    width: 40px;
    margin-left: 5px;
    margin-right: 5px;
    border-bottom: 2px solid black;
}

.codes-question {
    /* text-align: left; */
    min-height: 160px;
}

.regulations-question {
    /* text-align: left; */
    min-height: 100px;
}

.places-question {
    /* text-align: center; */
    min-height: 160px;
}

.routes-question {
    /* text-align: center; */
    min-height: 160px;
}

.percentage-bar {
    display: flex;
    width: 100%;
    height: 6px;
    background-color: #e0e0e0;
    /* border: 1px solid #ccc;
    border-radius: 3px; */
    overflow: hidden;
}

.percentage-bar-fill {
    height: 100%;
    flex-grow: 0;
    width: var(--percentage);
}

.dashboard-content {
    width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

/* .dashboard-content div:first-of-type {
    margin-right: auto;
} */

.dashboard-item {
    background-color: aliceblue;
    padding: 8px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    border-left: 5px solid var(--primary);
    box-shadow: 4px 4px 6px rgba(0,0,0,0.3);
    margin-bottom: 15px;
    /* margin-top: 5px; */
    width: 100%;
}

.dashboard-icon {
    text-align: center;
    font-size: 0.6rem;
}

.dashboard-icon img {
    display: block;
    width: 24px;
    margin-left: auto;
    margin-right: auto;
}

.pass {
    color: green;
}

.pass-bar {
    background-color: green;
}

.fail-bar {
    background-color: red;
}

.fail {
    color: red;
}

#quiz-question-header {
    display: flex;
    flex-direction: row;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    width: 100%;
    font-size: 0.8rem;
}

#quiz-question-header div {
    display: flex;
    flex-direction: row;
    align-items: center;
}

#quiz-question-number {
    flex: 1;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
}

#quiz-question-header img {
    display: inline-block;
    max-width: 24px;
    max-height: 24px;
}

.exam-question-number {
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
}

.circular-bg {
    fill: none;
    stroke: lightgray;
    stroke-width: 8px;
}

.circular-bar {
    fill: none;
    stroke: dimgray;
    stroke-width: 8px;
    stroke-dasharray: 314px;
    stroke-dashoffset: 314px;
    transition: stroke-dashoffset 1.5s ease-in-out;
    stroke-linecap: round;
}

.progress-text {
    font-size: 1.6rem;
    font-weight: bold;
    text-anchor: middle;
    fill: dimgray;
    dominant-baseline: central;
    font-family: sans-serif;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

img.bookmark-inactive {
    filter: saturate(30%) opacity(30%);
}

img.bookmark-active {
    filter: saturate(100%) opacity(100%);
}

#exam-timer {
    /* flex: 1; */
    text-align: right;
    font-size: 1rem;
    font-weight: 600;
    /* margin-left: auto; */
}

.exam-question-header {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    width: 100%;
    font-size: 0.8rem;
}

.exam-question-header img {
    display: inline-block;
    max-width: 24px;
    max-height: 24px;
}

.warning-red { color: red; font-weight: bold; transition: 0.5s; }

.exam-list-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(5, 1fr);
    grid-gap: 4px;
    width: 100%;
    margin-bottom: 6px;
}

.number-btn.answered {
    border: 2px solid var(--primary);
    background-color: lavender;
}

.number-btn.bookmarked {
    /* border: 2px solid var(--primary); */
    color: red;
}

.number-btn {
    display: block;
    margin: 0px;
    padding: 2px;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    /* transition: 0.3s; */
    font-size: 0.75rem;
    font-weight: bold;
    text-align: center;
    background-color: whitesmoke;
}

#exam-list-card label {
    width: 100%;
    margin-bottom: 6px;
}

.exam-list-legend-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    gap: 4px;
}

.exam-list-legend {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    margin-top: auto;
    margin-bottom: auto;
    font-size: 0.75rem;
}

.exam-result-graph {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    align-items: center;
    width: 100%;
    gap: 4px;
}

.exam-result-part {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* gap: 4px; */
}

.exam-result-score {
    font-size: 1.25rem;
    font-weight: bold;
}

#exam-result-message {
    font-size: 2.5rem;
    font-weight: bold;
    text-align: center;
}