/* Reset default styles for consistency */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base styles for body */
body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f4f4f4;
}

/* Dark mode styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #f4f4f4;
}

/* Header styles using Flexbox */
header {
    background: #2c3e50;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

header h1 {
    font-size: 2rem;
    margin-right: 1rem;
}

header button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    cursor: pointer;
    position: absolute;
    right: 0;
}

header button:hover {
    background-color: #2980b9;
}

/* Navigation bar using Flexbox */
nav {
    background: #3498db;
    padding: 1rem;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
}

nav ul li {
    margin: 0 1rem;
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    padding: 0.5rem 1rem;
    border-radius: 5px;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

nav ul li a:hover {
    background-color: #34495e;
    transform: scale(1.1);
}

/* Main layout using CSS Grid */
main {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

/* Card container using Flexbox */
.card-container {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Card styles with flip animation */
.card {
    background-color: #ecf0f1;
    padding: 1rem;
    border-radius: 5px;
    flex: 1 1 300px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    position: relative;
    perspective: 1000px; /* Enable 3D space for flip effect */
    cursor: pointer;
    transition: transform 0.6s ease;
    min-height: 250px; /* Fix: Ensure minimum height for content visibility */
}

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

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%; /* Fix: Full height for proper display */
    backface-visibility: hidden;
    padding: 1rem;
    border-radius: 5px;
    overflow: auto; /* Fix: Allow scrolling if content overflows */
}

.card-front {
    background-color: #ecf0f1;
}

.card-back {
    background-color: #3498db;
    color: white;
    transform: rotateY(180deg);
}

.card h3 {
    margin-bottom: 0.5rem;
}

.card p {
    margin-bottom: 1rem;
    color: #555;
    font-size: 1rem;
}

.card button {
    background-color: #3498db;
    color: #ecf0f1;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    padding: 0.625rem 1.25rem;
    font-size: 1rem;
    transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.card button:hover {
    background-color: #2980b9;
    transform: scale(1.05);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Subtle pulse animation for cards */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

.card:hover {
    animation: pulse 1.5s infinite ease-in-out;
}

/* Modal styles with slide-in animation */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background-color: white;
    padding: 2rem;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    position: relative;
    transform: translateY(-50px);
    animation: slideIn 0.3s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
}

.close:hover {
    color: #e74c3c;
}

/* Sidebar styles */
aside {
    background: #ecf0f1;
    padding: 1rem;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

aside:hover {
    background-color: #dfe6e9;
}

/* Form styles */
.form-section {
    margin: 0 auto;
    padding: 0.625rem;
    border: 1px solid #f4f4f4;
    border-radius: 8px;
}

.form-group {
    margin-bottom: 0.875rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.375rem;
}

.form-group input {
    width: 100%;
    padding: 0.625rem;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 5px;
}

.error {
    color: #e74c3c;
    font-size: 0.8rem;
}

.success {
    color: #2ecc71;
}

/* Quiz styles (new) */
#quiz-section {
    margin-top: 2rem;
}

#quiz-section input {
    margin-bottom: 1rem;
}

/* Footer styles */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: 2rem;
}

/* Responsive design */
@media (max-width: 768px) {
    main {
        grid-template-columns: 1fr;
    }
    nav ul {
        flex-direction: column;
        align-items: center;
    }
    nav ul li {
        margin: 0.5rem 0;
    }
    .card {
        flex: 1 1 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5rem;
    }
    main {
        padding: 1rem;
    }
    .card-container {
        flex-direction: column;
    }
    .modal-content {
        width: 95%;
    }
}