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

:root {
    --primary: #4f46e5;
    --primary-dark: #8e85f3;
    --third: #cc4c1a;
    --third-dark: #ec5845;
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --info: #3b82f6;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
}

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

header {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

header h1 {
    color: var(--primary);
    font-size: 2rem;
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

main {
    display: grid;
    gap: 24px;
}

.card-form,
.card-list-section,
.study-section {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}

h2 {
    color: var(--text);
    margin-bottom: 20px;
    font-size: 1.5rem;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text);
}

.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

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

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

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

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

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-info {
    background: var(--info);
    color: white;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-large {
    padding: 14px 28px;
    font-size: 1.125rem;
    width: 100%;
}

/* Flashcard List */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.list-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.flashcard-list {
    display: grid;
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.flashcard-item {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
}

.flashcard-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.flashcard-item.selected {
    background: #eef2ff;
    border-color: var(--primary);
}

.flashcard-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.flashcard-content-item {
    flex: 1;
    display: grid;
    gap: 8px;
}

.flashcard-side {
    font-size: 0.95rem;
}

.flashcard-side strong {
    color: var(--primary);
    margin-right: 8px;
}

.flashcard-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.3s;
}

.icon-btn:hover {
    background: var(--border);
}

.edit-btn {
    color: var(--info);
}

.delete-btn {
    color: var(--danger);
}

.empty-state {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
    font-style: italic;
}

/* Study Mode */
.study-controls {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.study-controls label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    cursor: pointer;
}

.study-controls input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.3s;
}

.close-btn:hover {
    background: var(--border);
}

.modal-body {
    padding: 24px;
}

.study-progress {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    color: var(--text-light);
    font-weight: 600;
}

.flashcard-display {
    perspective: 1000px;
    margin-bottom: 24px;
}

.flashcard {
    width: 100%;
    height: 350px;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    font-size: 1.5rem;
    text-align: center;
    backface-visibility: hidden;
    box-shadow: var(--shadow-lg);
    transition: transform 0.6s;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: linear-gradient(135deg, var(--third) 0%, var(--third-dark) 100%);

}

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

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

.flashcard-content {
    position: absolute;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    font-size: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transition: all 0.4s ease;
}

.flashcard-content.flip-animation {
    animation: flipCard 0.4s ease;
}

@keyframes flipCard {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(0.95);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.study-navigation {
    display: flex;
    padding-top: 12px;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: stretch;
    }

    header h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    .header-actions {
        justify-content: center;
    }

    .list-header {
        flex-direction: column;
        align-items: stretch;
    }

    .list-actions {
        justify-content: center;
    }

    .flashcard-item {
        flex-direction: column;
        align-items: stretch;
    }

    .flashcard-actions {
        justify-content: flex-end;
    }

    .study-controls {
        flex-direction: column;
    }

    .flashcard-content {
        font-size: 1.2rem;
        padding: 24px;
    }

    .study-navigation {
        flex-direction: column;
    }
}

/* Scrollbar Styling */
.flashcard-list::-webkit-scrollbar {
    width: 8px;
}

.flashcard-list::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

.flashcard-list::-webkit-scrollbar-thumb {
    background: var(--secondary);
    border-radius: 4px;
}

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