/*
 * Copyright Tarushv Kosgi 2025
 */
:root {
    --primary-color: #0071e3;
    --secondary-color: #86868b;
    --background-color: #ffffff;
    --surface-color: #f5f5f7;
    --text-color: #1d1d1f;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --primary-color: #2997ff;
    --secondary-color: #86868b;
    --background-color: #000000;
    --surface-color: #1d1d1f;
    --text-color: #f5f5f7;
}

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

body {
    font-family: Helvetica, "Helvetica Neue", -apple-system, BlinkMacSystemFont, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.47059;
    letter-spacing: -0.022em;
    font-weight: 400;
    transition: background-color 0.3s, color 0.3s;
}

header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    padding: 0.8rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

main {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.screen {
    display: none;
}

.screen.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 200px); /* Account for header and footer */
}

#welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#welcome-screen h2 {
    text-align: center;
    margin-bottom: 1rem;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.4rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease-out;
    font-size: 0.9rem;
    letter-spacing: -0.01em;
    font-weight: 400;
    min-width: 28px;
    min-height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    background-color: var(--primary-color);
}

button:active {
    transform: translateY(0);
    opacity: 0.8;
}

.hidden {
    display: none;
}

/* Welcome Screen Styles */
.study-options {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2rem;
    padding: 0 1rem;
    height: 100%;
    flex: 1;
}

.study-options > * {
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#importBtn, #useSampleBtn {
    margin-bottom: 1rem;
}

/* Study Screen Styles */
.mode-selector {
    display: flex;
    gap: 0.8rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    justify-content: center;
}

.mode-selector button {
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid var(--secondary-color);
    padding: 0.4rem 1rem;
}

.mode-selector button:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Flashcard Mode Styles */
.flashcard {
    width: 100%;
    max-width: 600px;
    height: 280px;
    margin: 1.5rem auto;
    perspective: 1000px;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--border-radius);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.flashcard-back {
    transform: rotateY(180deg);
}

.controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1rem;
}

/* Learn Mode Styles */
.learn-mode {
    max-width: 600px;
    margin: 0 auto;
}

.answer-input {
    width: 100%;
    padding: 1rem;
    margin: 1rem 0;
    border: 2px solid var(--surface-color);
    border-radius: 6px;
    background-color: var(--surface-color);
    color: var(--text-color);
    font-size: 1rem;
}

.answer-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--background-color);
}

.answer-input.correct {
    border-color: #4caf50;
    background-color: rgba(76, 175, 80, 0.1);
}

.answer-input.incorrect {
    border-color: #f44336;
    background-color: rgba(244, 67, 54, 0.1);
}

.feedback {
    padding: 1rem;
    margin: 1rem 0;
    border-radius: var(--border-radius);
    background-color: var(--surface-color);
    color: var (--text-color);
}

/* Match Mode Styles */
.match-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.match-card {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: saturate(180%) blur(20px);
    border-radius: 8px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.match-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.match-card.selected {
    background-color: var(--primary-color);
    color: white;
}

.match-card.matched {
    background-color: #4caf50;
    color: white;
    cursor: default;
}

/* Test Mode Styles */
.question {
    max-width: 800px;
    margin: 0 auto;
}

.question .term {
    font-size: 1.5rem;
    margin: 2rem 0;
    text-align: center;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 2rem 0;
}

.option {
    text-align: left;
    padding: 0.8rem 1rem;
    background-color: var(--surface-color);
    color: var(--text-color);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    font-size: 0.95rem;
}

.option:hover:not(:disabled) {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.option.correct {
    background-color: #4caf50;
    color: white;
}

.option.incorrect {
    background-color: #f44336;
    color: white;
}

/* Results Styles */
.results {
    text-align: center;
    padding: 2rem;
}

.results .grade {
    font-size: 4rem;
    font-weight: bold;
    margin: 2rem 0;
}

/* Progress Indicator */
.progress-bar {
    width: 100%;
    height: 3px;
    background-color: var(--surface-color);
    margin: 0.8rem 0;
    border-radius: 1.5px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, #47a4ff 100%);
    transition: width 0.3s ease;
}

/* Footer Styles */
footer {
    background-color: var(--surface-color);
    padding: 1rem;
    text-align: center;
    margin-top: 2rem;
    box-shadow: var(--shadow);
}

footer p {
    color: var(--text-color);
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mode-selector {
        flex-direction: column;
    }
    
    .mode-selector button {
        width: 100%;
    }
    
    .flashcard {
        height: 200px;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .match-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .question .term {
        font-size: 1.2rem;
    }
}

/* AI Prompt Section Styles */
.ai-prompt-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin: 0 auto;
    text-align: left;
    max-width: 600px;
    width: 100%;
    padding: 1rem;
    background: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.ai-steps {
    margin-bottom: 0.5rem;
}

.ai-steps p {
    margin: 0.25rem 0;
    font-size: 1rem;
    color: var(--text-color);
}

.ai-prompt {
    flex: 1;
    background: var(--background-color);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    overflow-x: auto;
    font-family: Menlo, Monaco, "Courier New", monospace;
    font-size: 0.9rem;
    color: var(--text-color);
    border: 1px solid var(--primary-color);
    white-space: pre-wrap;
    line-height: 1.2;
    margin: 0.5rem 0;
}

.prompt-tip {
    margin-top: 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
}