/* 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: #333;
    background-color: #f5f5f5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* App container */
.app-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    text-align: center;
}

/* Header */
header {
    margin-bottom: 30px;
}

header h1 {
    font-size: 2.8rem;
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    letter-spacing: 0.5px;
}

header h1 .italiano {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.progress {
    font-size: 1.1rem;
    color: #7f8c8d;
    font-weight: 500;
}

/* Card selector */
.card-selector {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card-selector label {
    font-size: 1rem;
    color: #2c3e50;
    font-weight: 500;
}

.card-selector input[type="number"] {
    width: 80px;
    padding: 8px 12px;
    font-size: 1rem;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.2s ease;
}

.card-selector input[type="number"]:focus {
    outline: none;
    border-color: #3498db;
}

.go-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 50px;
}

.go-btn:hover {
    background: #229954;
    transform: translateY(-1px);
}

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

.go-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

/* Card container */
.card-container {
    perspective: 1000px;
    margin-bottom: 40px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Card styling */
.card {
    width: 100%;
    height: 280px;
    max-width: 400px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease-in-out;
    cursor: pointer;
    user-select: none;
}

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

.card-front,
.card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    background: white;
    border: 1px solid #e1e8ed;
}

.card-back {
    transform: rotateY(180deg);
    background: #f8f9fa;
}

.word,
.definition {
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
    word-wrap: break-word;
    hyphens: auto;
}

.word {
    color: #2c3e50;
}

.definition {
    color: #34495e;
    font-size: 1.4rem;
    line-height: 1.4;
    font-weight: 400;
}

/* Adjust definition styling when on front */
.card-front .definition {
    font-size: 1.3rem;
    font-weight: 500;
    color: #2c3e50;
}

/* Adjust word styling when on back */
.card-back .word {
    font-size: 2.2rem;
    font-weight: 700;
    color: #e74c3c;
}

/* Audio button styling */
.audio-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #3498db;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.audio-btn:hover {
    background: #3498db;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

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

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

.audio-btn.playing {
    background: #e74c3c;
    border-color: #e74c3c;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Response section */
.response-section {
    margin-bottom: 25px;
    text-align: center;
    max-width: 100%;
}

.response-section label {
    display: block;
    font-size: 0.95rem;
    color: #2c3e50;
    font-weight: 500;
    margin-bottom: 12px;
}

.response-controls {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 8px;
    flex-wrap: wrap;
    max-width: 100%;
}

.response-controls input[type="text"] {
    flex: 1;
    min-width: 200px;
    max-width: 280px;
    padding: 10px 14px;
    font-size: 1rem;
    border: 2px solid #bdc3c7;
    border-radius: 6px;
    text-align: center;
    transition: border-color 0.2s ease;
}

.response-controls input[type="text"]:focus {
    outline: none;
    border-color: #3498db;
}

.speak-btn {
    background: #9b59b6;
    color: white;
    border: none;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}

.speak-btn:hover {
    background: #8e44ad;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(155, 89, 182, 0.3);
}

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

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

.speak-btn.playing {
    background: #e74c3c;
    animation: pulse 1.5s infinite;
}

.check-btn {
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 6px;
    width: 44px;
    height: 44px;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.check-btn:hover {
    background: #229954;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(39, 174, 96, 0.3);
}

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

.check-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Response feedback */
.response-feedback {
    margin-top: 12px;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    display: none;
    transition: all 0.3s ease;
    max-width: 100%;
}

.response-feedback.correct {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.response-feedback.incorrect {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Examples button section */
.examples-button-section {
    margin-bottom: 15px;
    text-align: center;
}

.examples-button-section .examples-content {
    margin-top: 15px;
}

.examples-toggle {
    background: #f39c12;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.examples-toggle:hover {
    background: #d68910;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(243, 156, 18, 0.3);
}

.examples-toggle:active {
    transform: translateY(0);
}

.examples-toggle.active {
    background: #e67e22;
}

/* Examples content */
.examples-content {
    max-width: 500px;
    margin: 0 auto;
    text-align: left;
}

.examples-list {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.example-item {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.example-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.example-sentence {
    font-size: 1rem;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 5px;
    font-style: italic;
}

.example-translation {
    font-size: 0.9rem;
    color: #6c757d;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.nav-btn,
.flip-btn,
.retry-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 44px;
    min-height: 44px;
}

.nav-btn {
    background: #3498db;
    color: white;
}

.nav-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

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

.nav-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
}

.flip-btn {
    background: #e74c3c;
    color: white;
}

.flip-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

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

.retry-btn {
    background: #27ae60;
    color: white;
    margin-top: 15px;
}

.retry-btn:hover {
    background: #229954;
}

/* Messages */
.error-message,
.loading-message {
    background: white;
    border-radius: 10px;
    padding: 30px;
    margin: 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.error-message {
    border-left: 4px solid #e74c3c;
}

.error-message p {
    color: #e74c3c;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.loading-message {
    border-left: 4px solid #3498db;
}

.loading-message p {
    color: #3498db;
    font-size: 1.1rem;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .app-container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .card-selector {
        flex-direction: row;
        gap: 8px;
        justify-content: center;
        align-items: center;
    }
    
    .card-selector input[type="number"] {
        width: 70px;
    }
    
    .card-container {
        height: 240px;
        margin-bottom: 20px;
    }
    
    .card {
        height: 210px;
    }
    
    .card-front,
    .card-back {
        padding: 18px;
    }
    
    .word {
        font-size: 1.6rem;
    }
    
    .definition {
        font-size: 1.2rem;
    }
    
    .response-section {
        margin-bottom: 20px;
    }
    
    .response-controls {
        gap: 6px;
    }
    
    .examples-section {
        margin-bottom: 20px;
    }
    
    .examples-toggle {
        font-size: 0.9rem;
        padding: 8px 16px;
    }
    
    .examples-list {
        padding: 16px;
    }
    
    .example-sentence {
        font-size: 0.95rem;
    }
    
    .example-translation {
        font-size: 0.85rem;
    }
    
    .response-controls input[type="text"] {
        min-width: 180px;
        font-size: 0.95rem;
        padding: 9px 12px;
    }
    
    .speak-btn,
    .check-btn {
        height: 40px;
    }
    
    .speak-btn {
        width: 40px;
        font-size: 1rem;
    }
    
    .check-btn {
        font-size: 1.2rem;
        width: 40px;
    }
    
    .controls {
        gap: 12px;
        margin-bottom: 20px;
    }
    
    .nav-btn,
    .flip-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 12px;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    .card-container {
        height: 200px;
        margin-bottom: 18px;
    }
    
    .card {
        height: 180px;
    }
    
    .word {
        font-size: 1.4rem;
    }
    
    .definition {
        font-size: 1.1rem;
    }
    
    .response-section {
        margin-bottom: 18px;
    }
    
    .response-controls {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 6px;
    }
    
    .examples-section {
        margin-bottom: 18px;
    }
    
    .examples-content {
        max-width: 100%;
    }
    
    .examples-list {
        padding: 14px;
    }
    
    .response-controls input[type="text"] {
        flex: 1;
        max-width: 180px;
        min-width: 140px;
    }
    
    .response-controls .speak-btn,
    .response-controls .check-btn {
        width: 40px;
        height: 40px;
    }
    
    .controls {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .nav-btn {
        width: 50px;
        padding: 10px 12px;
        font-size: 1.2rem;
    }
    
    .flip-btn {
        padding: 10px 18px;
        font-size: 0.9rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .card {
        transition: none;
    }
    
    .nav-btn:hover,
    .flip-btn:hover {
        transform: none;
    }
}

/* Focus styles for keyboard navigation */
.card:focus,
.nav-btn:focus,
.flip-btn:focus,
.retry-btn:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .card-front,
    .card-back {
        border: 2px solid #000;
    }
    
    .word,
    .definition {
        color: #000;
    }
}