/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #2d3748;
    background-color: #f7fafc;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #68d391 0%, #48bb78 100%);
    color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.back-link {
    color: white;
    text-decoration: none;
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    transition: background-color 0.3s ease;
}

.back-link:hover {
    background-color: rgba(255, 255, 255, 0.3);
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.subtitle {
    text-align: center;
    margin-top: 0.5rem;
    opacity: 0.9;
    font-size: 1.1rem;
}

/* Main content */
.main {
    flex: 1;
    padding: 2rem 0;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-primary {
    background-color: #4299e1;
    color: white;
}

.btn-primary:hover {
    background-color: #3182ce;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(66, 153, 225, 0.3);
}

.btn-success {
    background-color: #48bb78;
    color: white;
}

.btn-success:hover {
    background-color: #38a169;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(72, 187, 120, 0.3);
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    min-width: 200px;
}

/* Index page styles */
.section-title {
    text-align: center;
    color: #2d3748;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: 700;
}

.decks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.deck-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.deck-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #48bb78;
}

.deck-info h3 {
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.deck-stats {
    color: #48bb78;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.deck-date {
    color: #718096;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.deck-link {
    text-decoration: none;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #718096;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    color: #4a5568;
    margin-bottom: 1rem;
}

/* Deck page styles */
.deck-detail {
    max-width: 800px;
    margin: 0 auto;
}

.deck-header {
    text-align: center;
    margin-bottom: 2rem;
}

.deck-title {
    color: #2d3748;
    font-size: 2.5rem;
    margin-bottom: 1rem;
    font-weight: 700;
}

.deck-meta {
    display: flex;
    justify-content: center;
    gap: 2rem;
    color: #718096;
    font-size: 1.1rem;
}

.deck-actions {
    text-align: center;
    margin-bottom: 3rem;
}

.deck-description,
.study-tips {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.deck-description h3,
.study-tips h3 {
    color: #2d3748;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.study-tips ul {
    list-style: none;
    padding-left: 0;
}

.study-tips li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.study-tips li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #48bb78;
    font-weight: bold;
}

/* Study page styles */
.study-section {
    max-width: 1200px;
    margin: 0 auto;
}

.study-layout {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
    margin-bottom: 2rem;
}

.card-container {
    background: #ffffff;
    border-radius: 16px;
    min-height: 400px;
    flex: 1;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.card-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex-shrink: 0;
    width: 160px;
}

.card-controls .btn {
    min-width: 140px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    padding: 0.875rem 1rem;
}

.card-controls .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.card-controls .btn:not(:disabled):hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #718096;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #48bb78;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.card-face {
    padding: 2rem;
    min-height: 400px;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease;
}

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

.card-label {
    font-size: 0.9rem;
    color: #48bb78;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.card-content {
    flex: 1;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #2d3748;
}

.card-media {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e2e8f0;
}

.media-image {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.media-audio {
    width: 100%;
    margin-top: 0.5rem;
}

.card-progress {
    text-align: center;
    color: #718096;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    background-color: #2d3748;
    color: #e2e8f0;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

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

    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    .logo {
        font-size: 1.5rem;
    }

    .decks-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .deck-title {
        font-size: 2rem;
    }

    .deck-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

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

    .card-controls {
        flex-direction: row;
        justify-content: center;
        width: 100%;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 300px;
    }

    .progress-info {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* Animation for card flip */
.card-flip {
    animation: flip 0.6s ease;
}

@keyframes flip {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(90deg); }
    100% { transform: rotateY(0); }
}

/* Error state */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    color: #718096;
    text-align: center;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.7;
}

.error-state h3 {
    color: #e53e3e;
    margin-bottom: 1rem;
}

.error-state p {
    margin-bottom: 1.5rem;
}

/* Media items */
.media-item {
    margin-bottom: 1rem;
}

.media-filename {
    font-size: 0.8rem;
    color: #718096;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Enhanced card field styles */
.card-info {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.model-info,
.template-info {
    background: #f0fff4;
    color: #22543d;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #9ae6b4;
}

.template-info {
    background: #e6f3ff;
    color: #2c5282;
    border-color: #90cdf4;
}

.field-group {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid #48bb78;
}

.field-label {
    font-size: 0.85rem;
    color: #4a5568;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.field-content {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #2d3748;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.field-content:empty::after {
    content: "[No content]";
    color: #a0aec0;
    font-style: italic;
}

/* Card tags */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.tag {
    background: #edf2f7;
    color: #4a5568;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid #cbd5e0;
}

/* Template details */
.template-details {
    background: #f7fafc;
    border-radius: 8px;
    padding: 1.5rem;
    border: 1px solid #e2e8f0;
}

.template-details h4 {
    color: #2d3748;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.template-details p {
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
}

.template-details strong {
    color: #4a5568;
}

/* Enhanced flip animation for multiple fields */
.card-flip {
    animation: flip 0.6s ease;
}

@keyframes flip {
    0% {
        transform: rotateY(0);
        opacity: 1;
    }
    50% {
        transform: rotateY(90deg);
        opacity: 0.8;
    }
    100% {
        transform: rotateY(0);
        opacity: 1;
    }
}

/* Responsive field groups */
@media (max-width: 768px) {
    .field-group {
        padding: 0.75rem;
        margin-bottom: 1rem;
    }

    .card-info {
        flex-direction: column;
        gap: 0.5rem;
    }

    .field-content {
        font-size: 1.1rem;
    }

    .template-details p {
        flex-direction: column;
        gap: 0.25rem;
    }
}

hr {
    margin-top: 10px;
    margin-bottom: 10px;
}

audio {
    width: 100%;
    max-width: 400px;
}