:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --secondary-color: #8b5cf6;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--text-primary);
}

/* Sections */
.section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Auth Section */
#auth-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container {
    background: var(--bg-primary);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-container {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.app-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 10px 0;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.auth-form h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--border-color);
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

/* Header */
.header {
    background: var(--bg-primary);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-small {
    width: 40px;
    height: 40px;
    object-fit: contain;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    display: flex;
    gap: 10px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.nav-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-icon {
    font-size: 1.2rem;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

#username-display {
    font-weight: 600;
    color: var(--text-primary);
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.page-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 30px;
    text-align: center;
    color: white;
}

/* Stats */
.stats, .training-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.stat-item {
    background: var(--bg-primary);
    padding: 15px 30px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Cards */
.cards-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

#card-stack {
    position: relative;
    height: 400px;
}

.card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: grab;
    user-select: none;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:active {
    cursor: grabbing;
}

.card.swiping {
    transition: none;
}

.card.swipe-right {
    animation: swipeRight 0.5s forwards;
}

.card.swipe-left {
    animation: swipeLeft 0.5s forwards;
}

@keyframes swipeRight {
    to {
        transform: translateX(150%) rotate(20deg);
        opacity: 0;
    }
}

@keyframes swipeLeft {
    to {
        transform: translateX(-150%) rotate(-20deg);
        opacity: 0;
    }
}

.card-word {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 20px;
    cursor: pointer;
    transition: color 0.3s;
}

.card-word:hover {
    color: var(--primary-color);
}

.card-translation {
    font-size: 1.3rem;
    color: var(--text-secondary);
    text-align: center;
    display: none;
}

.card.flipped .card-translation {
    display: block;
    animation: fadeIn 0.3s;
}

.card-hint {
    position: absolute;
    bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
}

.swipe-hints {
    display: flex;
    justify-content: space-between;
    margin-top: 30px;
}

.swipe-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: white;
    font-weight: 600;
}

.swipe-hint span:first-child {
    font-size: 2rem;
}

/* Training */
.training-container {
    max-width: 600px;
    margin: 0 auto;
}

.training-card {
    background: var(--bg-primary);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.5s;
}

.training-question {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 30px;
}

.training-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.training-option {
    padding: 20px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 1.1rem;
}

.training-option:hover {
    border-color: var(--primary-color);
    background: var(--bg-primary);
    transform: translateY(-2px);
}

.training-option.correct {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
    animation: pulse 0.5s;
}

.training-option.incorrect {
    background: var(--danger-color);
    color: white;
    border-color: var(--danger-color);
    animation: shake 0.5s;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

#start-training-btn {
    display: block;
    margin: 30px auto 0;
    max-width: 300px;
}

/* Words Management */
.add-word-form {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.add-word-form h3 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1rem;
}

.form-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row .btn {
    width: auto;
}

.words-list {
    display: grid;
    gap: 15px;
}

.word-item {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 15px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    animation: slideUp 0.3s;
}

.word-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.word-content {
    flex: 1;
}

.word-english {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.word-russian {
    color: var(--text-secondary);
}

.word-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all 0.3s;
}

.btn-delete {
    background: var(--danger-color);
    color: white;
}

.btn-delete:hover {
    background: #dc2626;
    transform: scale(1.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-primary);
    padding: 40px;
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.3s;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.modal-close:hover {
    color: var(--text-primary);
}

#modal-body h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

#modal-body p {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-primary);
    padding: 15px 20px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    min-width: 250px;
    animation: slideInRight 0.3s;
}

.toast.success {
    border-left: 4px solid var(--success-color);
}

.toast.error {
    border-left: 4px solid var(--danger-color);
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        flex-wrap: wrap;
    }

    .nav {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .form-row {
        flex-direction: column;
    }

    .training-options {
        grid-template-columns: 1fr;
    }

    .stats, .training-stats {
        flex-direction: column;
        align-items: stretch;
    }
}

/* Loading animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
