/* ===== CSS Variables ===== */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --success-color: #22c55e;
    --success-light: #86efac;
    --error-color: #ef4444;
    --error-light: #fca5a5;
    --warning-color: #f59e0b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-lg: 20px;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

/* ===== App Container ===== */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--background);
    position: relative;
    overflow: hidden;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.screen-time-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.time-icon {
    font-size: 1.1rem;
}

.settings-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 1.3rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* ===== Screens ===== */
.screen {
    display: none;
    padding: 24px;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

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

/* ===== Main Screen ===== */
.welcome-section {
    text-align: center;
    margin-bottom: 24px;
}

.welcome-section h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.motivation-text {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Progress Card */
.progress-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}

.progress-card h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.progress-bar-container {
    background: var(--border-color);
    height: 16px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--success-color));
    width: 0%;
    border-radius: 8px;
    transition: width 0.5s ease;
}

/* Direction Selector */
.direction-selector {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.direction-selector label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.direction-buttons {
    display: flex;
    gap: 12px;
}

.direction-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    background: var(--card-bg);
    border-radius: var(--radius);
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.direction-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
    color: var(--primary-dark);
}

.direction-btn:hover:not(.active) {
    border-color: var(--primary-light);
}

/* Stats Section */
.stats-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ===== Buttons ===== */
.primary-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn.large {
    width: 100%;
    padding: 18px;
    font-size: 1.2rem;
}

.secondary-btn {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.secondary-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.small-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.small-btn:hover {
    background: var(--primary-dark);
}

.danger-btn {
    background: var(--error-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.danger-btn:hover {
    background: #dc2626;
}

.back-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    padding: 8px;
    transition: color 0.3s ease;
}

.back-btn:hover {
    color: var(--primary-color);
}

/* ===== Learning Screen ===== */
.learning-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.session-progress {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
}

.vocabulary-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
    margin-bottom: 24px;
}

.word-display {
    margin-bottom: 32px;
}

.language-label {
    display: inline-block;
    background: var(--border-color);
    color: var(--text-secondary);
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.word {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.input-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.translation-input {
    width: 100%;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1.2rem;
    text-align: center;
    transition: border-color 0.3s ease;
}

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

.translation-input.correct {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.translation-input.incorrect {
    border-color: var(--error-color);
    background: #fef2f2;
}

/* Feedback */
.feedback {
    margin-top: 20px;
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.feedback.success {
    background: var(--success-light);
    color: #166534;
}

.feedback.error {
    background: var(--error-light);
    color: #991b1b;
}

.feedback.hidden {
    display: none;
}

.feedback-icon {
    font-size: 1.4rem;
}

/* Hint Section */
.hint-section {
    text-align: center;
    margin-bottom: 20px;
}

.hint-btn {
    background: none;
    border: 2px dashed var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
}

.hint-btn:hover {
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.hint-text {
    margin-top: 12px;
    color: var(--warning-color);
    font-style: italic;
}

.hint-text.hidden {
    display: none;
}

#next-word-btn {
    width: 100%;
}

#next-word-btn.hidden {
    display: none;
}

/* ===== Success Screen ===== */
.success-content {
    text-align: center;
    padding-top: 40px;
}

.success-animation {
    font-size: 5rem;
    animation: bounce 1s ease infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

.success-content h2 {
    font-size: 2rem;
    margin: 20px 0;
    color: var(--success-color);
}

.success-message {
    font-size: 1.2rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.reward-display {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
}

.reward-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 12px;
}

.reward-time {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--warning-color);
}

.reward-label {
    display: block;
    color: #92400e;
    margin-top: 8px;
}

.success-content .primary-btn {
    margin-bottom: 16px;
    width: 100%;
}

.success-content .secondary-btn {
    width: 100%;
}

/* ===== Code Screen ===== */
.code-content {
    text-align: center;
    padding-top: 60px;
}

.code-content h2 {
    font-size: 1.8rem;
    margin-bottom: 16px;
}

.code-input-container {
    margin: 32px 0;
}

.code-input {
    width: 150px;
    padding: 16px;
    font-size: 2rem;
    text-align: center;
    letter-spacing: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    transition: border-color 0.3s ease;
}

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

.code-content .primary-btn {
    width: 100%;
    margin-bottom: 12px;
}

.code-content .secondary-btn {
    width: 100%;
}

.error-text {
    color: var(--error-color);
    margin-top: 16px;
    font-weight: 600;
}

.error-text.hidden {
    display: none;
}

/* ===== Settings Screen ===== */
.settings-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.settings-header h2 {
    font-size: 1.4rem;
}

.settings-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.settings-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.settings-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.setting-item {
    margin-bottom: 16px;
}

.setting-item:last-child {
    margin-bottom: 0;
}

.setting-item label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.range-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-container input[type="range"] {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    background: var(--border-color);
    border-radius: 4px;
    outline: none;
}

.range-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow);
}

.settings-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
    font-style: italic;
}

.reward-summary {
    background: var(--primary-light);
    padding: 16px;
    border-radius: var(--radius);
    text-align: center;
    margin-top: 16px;
}

.reward-summary p {
    color: var(--primary-dark);
    margin: 0;
}

.time-management,
.stats-management {
    text-align: center;
}

.time-management p,
.stats-management p {
    margin-bottom: 12px;
    color: var(--text-secondary);
}

.stats-management .danger-btn {
    margin-top: 8px;
}

/* ===== Responsive ===== */
@media (min-width: 481px) {
    .app-container {
        margin-top: 20px;
        margin-bottom: 20px;
        border-radius: var(--radius-lg);
        box-shadow: var(--shadow-lg);
        min-height: calc(100vh - 40px);
    }
}

/* ===== Animations ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.3s ease;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse {
    animation: pulse 0.3s ease;
}

/* ===== Action Buttons (Main Screen) ===== */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.secondary-btn.large {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
}

.vocab-count-info {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* ===== Add Vocabulary Screen ===== */
.add-vocab-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.add-vocab-header h2 {
    font-size: 1.4rem;
}

.add-vocab-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.add-vocab-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.add-vocab-instruction {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.vocab-input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.vocab-input-field label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.vocab-input {
    width: 100%;
    padding: 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1.1rem;
    transition: border-color 0.3s ease;
}

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

.vocab-input.valid {
    border-color: var(--success-color);
    background: #f0fdf4;
}

.vocab-input.invalid {
    border-color: var(--error-color);
    background: #fef2f2;
}

/* Translation Check Result */
.translation-check {
    padding: 16px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.translation-check.hidden {
    display: none;
}

.translation-check.success {
    background: var(--success-light);
    color: #166534;
}

.translation-check.error {
    background: var(--error-light);
    color: #991b1b;
}

.translation-check .check-icon {
    font-size: 1.3rem;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    color: var(--text-secondary);
}

.loading-indicator.hidden {
    display: none;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* My Vocabulary List Section */
.my-vocab-list-section {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.my-vocab-list-section h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.my-vocab-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.empty-list-message {
    color: var(--text-secondary);
    text-align: center;
    font-style: italic;
    padding: 20px;
}

.vocab-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
    margin-bottom: 8px;
}

.vocab-item:last-child {
    margin-bottom: 0;
}

.vocab-item-words {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.vocab-item-de {
    font-weight: 600;
    color: var(--text-primary);
}

.vocab-item-arrow {
    color: var(--text-secondary);
}

.vocab-item-en {
    color: var(--primary-color);
    font-weight: 500;
}

.vocab-item-delete {
    background: none;
    border: none;
    color: var(--error-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.vocab-item-delete:hover {
    background: var(--error-light);
}

#clear-all-vocab-btn {
    width: 100%;
    margin-top: 8px;
}

#clear-all-vocab-btn.hidden {
    display: none;
}

/* Scrollbar Styling */
.my-vocab-list::-webkit-scrollbar {
    width: 6px;
}

.my-vocab-list::-webkit-scrollbar-track {
    background: var(--border-color);
    border-radius: 3px;
}

.my-vocab-list::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 3px;
}

.my-vocab-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}
