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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Input Section */
.input-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid #f0f0f0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tab-btn:hover {
    color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

#markdown-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
    margin-bottom: 20px;
    background: white;
    color: #333;
    outline: none;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

#ai-input {
    width: 100%;
    padding: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.3s ease;
    margin-bottom: 20px;
    background: white;
    color: #333;
    outline: none;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

#markdown-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#ai-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.url-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

#url-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: white;
    color: #333;
    outline: none;
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

#url-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.url-note {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 8px;
    color: #666;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.generate-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: fit-content;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

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

/* Flashcards Section */
.flashcards-section {
    background: white;
    border-radius: 16px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.section-header h2 {
    color: #333;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.controls {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.control-btn {
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-btn:hover {
    background: #e9ecef;
    border-color: #d0d0d0;
}

/* Progress Bar */
.progress-bar {
    background: #f0f0f0;
    height: 8px;
    border-radius: 4px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
}

.progress-fill {
    background: linear-gradient(90deg, #667eea, #764ba2);
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    position: absolute;
    top: -25px;
    right: 0;
    font-size: 14px;
    font-weight: 500;
    color: #666;
}

/* Flashcard */
.flashcard-container {
    perspective: 1000px;
    margin-bottom: 30px;
}

.flashcard {
    width: 100%;
    height: 450px;
    position: relative;
    cursor: pointer;
}

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

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

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 25px;
    overflow: hidden;
}

.flashcard-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.flashcard-back {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    transform: rotateY(180deg);
}

.card-content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    font-size: 1.2rem;
    font-weight: 500;
    text-align: left;
    line-height: 1.5;
    margin-bottom: 20px;
    overflow-y: auto;
    padding: 10px;
    word-wrap: break-word;
    hyphens: auto;
    max-height: 280px;
}

/* Custom scrollbar for card content */
.card-content::-webkit-scrollbar {
    width: 6px;
}

.card-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.card-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.card-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Better text formatting */
.card-content h1, .card-content h2, .card-content h3 {
    margin: 0 0 10px 0;
    font-size: 1.1em;
}

.card-content p {
    margin: 0 0 10px 0;
}

.card-content ul, .card-content ol {
    margin: 0 0 10px 20px;
    padding-left: 0;
}

.card-content li {
    margin-bottom: 5px;
}

.card-content code {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9em;
}

.card-content pre {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 6px;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85em;
    margin: 10px 0;
}

.flip-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flip-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.answer-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.difficulty-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 100px;
    justify-content: center;
}

.difficulty-btn.easy {
    background: #28a745;
    color: white;
}

.difficulty-btn.medium {
    background: #ffc107;
    color: #333;
}

.difficulty-btn.hard {
    background: #dc3545;
    color: white;
}

.difficulty-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Navigation */
.navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
}

.nav-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-2px);
}

.nav-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.6;
}

.card-counter {
    font-size: 18px;
    font-weight: 500;
    color: #666;
}

/* Statistics */
.statistics {
    background: white;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.statistics h3 {
    color: #333;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* AI Generation Styles */
.ai-options {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
}

.ai-option {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 14px;
    cursor: pointer;
}

.ai-option:last-child {
    margin-bottom: 0;
    justify-content: space-between;
}

.ai-option input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.2);
}

.ai-option select {
    padding: 6px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: white;
    font-size: 14px;
}

.ai-generate-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.ai-generate-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #e53935 100%);
}

.ai-status {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #b3d9ff;
    margin-top: 15px;
}

.ai-progress {
    background: #e0e0e0;
    height: 6px;
    border-radius: 3px;
    margin-bottom: 10px;
    overflow: hidden;
}

.ai-progress-bar {
    background: linear-gradient(90deg, #ff6b6b, #ee5a52);
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.ai-message {
    font-size: 14px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #ff6b6b;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .input-section, .flashcards-section, .statistics {
        padding: 20px;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .controls {
        width: 100%;
        justify-content: center;
    }

    .flashcard {
        height: 400px;
    }

    .card-content {
        font-size: 1.1rem;
        max-height: 250px;
    }

    .url-input-group {
        flex-direction: column;
    }

    .answer-buttons {
        flex-direction: column;
        width: 100%;
    }

    .difficulty-btn {
        width: 100%;
    }

    .navigation {
        flex-direction: row;
    }

    .nav-btn {
        flex: 1;
        max-width: 140px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .card-content {
        font-size: 1rem;
        max-height: 200px;
    }

    .flashcard {
        height: 350px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}
