/* Flashcard Container */
.afc-flashcard-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Header */
.afc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.afc-progress {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.afc-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.afc-got-it-btn {
    background: #28a745;
}

@media (hover: hover) {
    .afc-got-it-btn:hover {
        background: #218838;
    }
}

.afc-got-it-btn.active {
    background: #1e7e34;
    position: relative;
}

.afc-got-it-btn.active::after {
    content: ' ✓';
    font-weight: bold;
}

.afc-btn {
    padding: 10px 20px;
    background: #2271b1;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.3s ease;
}

@media (hover: hover) {
    .afc-btn:hover {
        background: #135e96;
    }
}

.afc-btn:active {
    transform: scale(0.98);
}

.afc-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Flashcard Wrapper */
.afc-flashcard-wrapper {
    position: relative;
    width: 100%;
    min-height: 400px;
    max-height: calc(100vh - 300px); /* Ensure space for buttons and header */
    height: 500px;
    margin-bottom: 20px;
    touch-action: pan-y pinch-zoom;
}

/* Individual Flashcard */
.afc-flashcard {
    position: absolute;
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.afc-flashcard.swipe-left {
    transform: translateX(-100%);
    opacity: 0;
}

.afc-flashcard.swipe-right {
    transform: translateX(100%);
    opacity: 0;
}

/* Card */
.afc-card {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 300px); /* Match wrapper constraint */
    perspective: 1000px;
    cursor: pointer;
}

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

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

.afc-card-front,
.afc-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    background: white;
    color: black;
    border: 2px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.afc-card-back {
    transform: rotateY(180deg);
}

/* Card Content */
.afc-card-image-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow: hidden;
}

.afc-card-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: pointer;
}

.afc-card-text {
    padding: 20px;
    font-size: 20px;
    line-height: 1.6;
    text-align: center;
    color: black;
    overflow-y: auto;
    max-height: 200px;
}

/* Center text when it's the only content */
.afc-card-front:not(:has(.afc-card-image-container)):not(:has(.afc-card-audio)) .afc-card-text,
.afc-card-back:not(:has(.afc-card-image-container)):not(:has(.afc-card-audio)) .afc-card-text {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    max-height: none;
}

/* Also center when only audio is present */
.afc-card-front:not(:has(.afc-card-image-container)) .afc-card-text,
.afc-card-back:not(:has(.afc-card-image-container)) .afc-card-text {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: none;
}

.afc-card-audio {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
}

.afc-audio-btn {
    width: 100%;
    padding: 12px 20px;
    background: #2271b1;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background 0.3s ease;
}

@media (hover: hover) {
    .afc-audio-btn:hover {
        background: #135e96;
    }
}

.afc-audio-btn:active {
    transform: scale(0.98);
}

.afc-audio-icon {
    font-size: 20px;
}

/* Navigation */
.afc-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
}

.afc-prev-btn,
.afc-next-btn {
    flex: 1;
    padding: 12px 24px;
    font-size: 16px;
}

/* Swipe Hint */
.afc-swipe-hint {
    text-align: center;
    color: #666;
    font-size: 14px;
    font-style: italic;
    display: none;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .afc-flashcard-container {
        padding: 15px;
    }
    
    .afc-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .afc-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .afc-flashcard-wrapper {
        height: 400px;
        max-height: calc(100vh - 250px);
        min-height: 300px;
    }
    
    .afc-card {
        max-height: calc(100vh - 250px);
    }
    
    .afc-card-text {
        font-size: 18px;
        padding: 15px;
    }
    
    .afc-swipe-hint {
        display: block;
    }
    
    .afc-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .afc-flashcard-container {
        padding: 10px;
    }
    
    .afc-flashcard-wrapper {
        height: 350px;
        max-height: calc(100vh - 220px);
        min-height: 250px;
    }
    
    .afc-card {
        max-height: calc(100vh - 220px);
    }
    
    .afc-card-text {
        font-size: 16px;
        padding: 12px;
        max-height: 150px;
    }
    
    .afc-navigation {
        flex-direction: column;
    }
    
    .afc-prev-btn,
    .afc-next-btn {
        width: 100%;
    }
}

/* Height-based media queries for vertical responsiveness */
@media (max-height: 700px) {
    .afc-flashcard-wrapper {
        height: auto;
        max-height: calc(100vh - 250px);
        min-height: 300px;
    }
    
    .afc-card {
        max-height: calc(100vh - 250px);
    }
    
    .afc-card-text {
        font-size: 16px;
        max-height: 120px;
    }
}

@media (max-height: 600px) {
    .afc-flashcard-container {
        padding: 10px;
    }
    
    .afc-flashcard-wrapper {
        max-height: calc(100vh - 200px);
        min-height: 250px;
    }
    
    .afc-card {
        max-height: calc(100vh - 200px);
    }
    
    .afc-header {
        margin-bottom: 10px;
    }
    
    .afc-navigation {
        margin-bottom: 10px;
    }
    
    .afc-card-text {
        font-size: 14px;
        padding: 10px;
        max-height: 100px;
    }
    
    .afc-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .afc-prev-btn,
    .afc-next-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
}

@media (max-height: 500px) {
    .afc-flashcard-wrapper {
        max-height: calc(100vh - 180px);
        min-height: 200px;
    }
    
    .afc-card {
        max-height: calc(100vh - 180px);
    }
    
    .afc-card-text {
        font-size: 13px;
        padding: 8px;
        max-height: 80px;
    }
    
    .afc-card-image-container {
        padding: 10px;
    }
}

/* Loading State */
.afc-flashcard-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.afc-flashcard {
    animation: fadeIn 0.3s ease;
}

/* Accessibility */
.afc-btn:focus,
.afc-audio-btn:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* No scrolling on cards */
.afc-card-front,
.afc-card-back {
    overflow: hidden;
}

.afc-card-text::-webkit-scrollbar {
    width: 6px;
}

.afc-card-text::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.afc-card-text::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.afc-card-text::-webkit-scrollbar-thumb:hover {
    background: #555;
}
