/* CSS Variables for theming */
:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --card-bg: #ffffff;
    --card-border: #ddd;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --button-bg: #007bff;
    --button-hover: #0056b3;
    --button-disabled: #6c757d;
    --input-bg: #ffffff;
    --input-border: #ddd;
    --selector-bg: #f8f9fa;
    --selector-border: #dee2e6;
    --error-color: #dc3545;
    --success-color: #28a745;
    --warning-color: #ffc107;
}

/* Dark mode variables */
[data-theme="dark"] {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --card-bg: #2d2d2d;
    --card-border: #404040;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --button-bg: #0d6efd;
    --button-hover: #0b5ed7;
    --button-disabled: #495057;
    --input-bg: #2d2d2d;
    --input-border: #404040;
    --selector-bg: #343a40;
    --selector-border: #495057;
    --error-color: #dc3545;
    --success-color: #198754;
    --warning-color: #ffc107;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Arial', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    padding: 20px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

/* Header controls */
.header-controls {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.language-selector {
    position: relative;
    z-index: 1000;
}

.language-toggle {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    color: var(--text-color);
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: bold;
    min-width: 60px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.language-toggle:hover {
    background: var(--selector-bg);
    transform: scale(1.05);
}

.language-toggle:active {
    transform: scale(0.95);
}

.language-toggle i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.language-toggle.open i {
    transform: rotate(180deg);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--card-shadow);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    margin-top: 5px;
}

.language-dropdown.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.language-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid var(--selector-border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.language-option:last-child {
    border-bottom: none;
}

.language-option:hover {
    background: var(--selector-bg);
}

.language-option.selected {
    background: var(--button-bg);
    color: white;
}

.language-option .language-code {
    font-weight: bold;
    min-width: 30px;
}

.language-option .language-name {
    flex: 1;
}

.dark-mode-toggle {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    color: var(--text-color);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.dark-mode-toggle:hover {
    background: var(--selector-bg);
    transform: scale(1.05);
}

.dark-mode-toggle:active {
    transform: scale(0.95);
}

/* Additional dark mode styles */
.selector-group label {
    color: var(--text-color);
}

.selector-instructions {
    color: var(--text-color);
}

.progress-bar {
    background-color: var(--selector-bg);
    border: 1px solid var(--selector-border);
}

.progress-fill {
    background-color: var(--button-bg);
}

/* Recording status styles */
.recording-status {
    color: var(--text-color);
}

/* API key input styles */
.api-key-input input {
    background-color: var(--input-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
}

h1 {
    margin-bottom: 30px;
    color: #333;
}

/* Dark mode h1 styling */
[data-theme="dark"] h1 {
    color: #e0e0e0;
}

.file-input {
    margin-bottom: 30px;
}

.file-input label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.flashcard-container {
    margin-top: 20px;
}

.flashcard {
    width: 100%;
    height: 300px;
    perspective: 1000px;
    cursor: pointer;
    margin-bottom: 20px;
    position: relative;
}

.card-content {
    width: 100%;
    height: 100%;
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 2px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 4px 8px var(--card-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-size: 24px;
    transition: all 0.3s;
    position: relative;
}

/* Controls overlay inside the card */
.card-controls-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    opacity: 1;
    pointer-events: all;
}

/* Navigation buttons - vertically centered */
.nav-btn {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.nav-btn:disabled {
    background: rgba(0, 0, 0, 0.3);
    cursor: not-allowed;
    transform: none;
}

/* Center controls positioned at bottom */
.center-controls {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(0, 123, 255, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 18px;
}

.control-btn:hover:not(:disabled) {
    background: rgba(0, 123, 255, 1);
    transform: scale(1.1);
}

.control-btn:disabled {
    background: rgba(108, 117, 125, 0.5);
    cursor: not-allowed;
    transform: none;
}

/* Recording button active state */
.control-btn.recording {
    background: rgba(220, 53, 69, 0.8);
    animation: pulse 1.5s infinite;
}

.control-btn.recording:hover {
    background: rgba(220, 53, 69, 1);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Card info below the flashcard */
.card-info {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 15px;
    padding: 0 10px;
}

.recording-status {
    font-size: 14px;
    color: var(--text-color);
    min-height: 20px;
    text-align: center;
}

.card-content.correct-pronunciation {
    background-color: rgba(15, 157, 88, 0.1); /* Light green background */
    border: 2px solid #0f9d58; /* Green border */
}

.card-content.incorrect-pronunciation {
    background-color: rgba(219, 68, 55, 0.1); /* Light red background */
    border: 2px solid #db4437; /* Red border */
}

.card-content p {
    max-width: 100%;
    word-wrap: break-word;
}

.navigation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.navigation button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

#card-counter {
    font-size: 20px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

.speech-controls {
    margin-top: 20px;
    font-size: 16px;
}

.speech-controls label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.speech-controls input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.api-key-input {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: none; /* Hidden by default */
}

.api-key-input.visible {
    display: block;
}

.api-key-input label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.api-key-input input {
    padding: 8px;
    width: 300px;
    margin-right: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.api-key-input button {
    padding: 8px 16px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.api-key-input button:hover {
    background-color: #3367d6;
}

.card-controls {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.card-controls button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 18px;
    background-color: #4285f4;
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.card-controls button:hover {
    background-color: #3367d6;
    transform: scale(1.05);
}

.card-controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

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

.selector-group {
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.selector-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
}

.selector-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.selector-group select:disabled {
    background-color: var(--selector-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

button {
    padding: 10px 20px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

button:hover {
    background-color: var(--button-hover);
    transform: scale(1.05);
}

button:disabled {
    background-color: var(--button-disabled);
    cursor: not-allowed;
    transform: none;
}

.card-controls {
    display: flex;
    justify-content: center;
    margin-top: 20px;
}

#pronounce-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

/* Speech Recognition Styles */
.speech-recognition {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
}

#record-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background-color: #4285f4; /* Blue when not recording */
    transition: all 0.3s ease;
    user-select: none; /* Prevent text selection during press */
    touch-action: manipulation; /* Improve touch behavior */
}

#record-btn:hover {
    background-color: #3367d6;
    transform: scale(1.05);
}

#record-btn:active {
    transform: scale(1.1);
}

#record-btn.recording {
    background-color: #db4437; /* Red only when actually recording */
    transform: scale(1.1);
}

#record-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    transform: none;
}

.recording-status {
    margin-top: 10px;
    font-size: 14px;
    min-height: 20px;
    color: #666;
    transition: all 0.3s ease;
}

/* Word comparison styles */
.match {
    color: #0f9d58;
    font-weight: bold;
}

.no-match {
    color: #db4437;
    font-weight: bold;
}

.comparison-result {
    margin-top: 10px;
    padding: 10px;
    border-radius: 5px;
    background-color: #f8f9fa;
    font-size: 16px;
    text-align: left;
    max-width: 100%;
    word-wrap: break-word;
}

.selector-instructions {
    margin-top: 15px;
    font-size: 16px;
    color: #666;
    text-align: center;
    width: 100%;
}

@media (max-width: 768px) {
    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .selector-instructions {
        font-size: 14px;
        margin-top: 10px;
    }
}
/* Selectors container */
.selectors {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
}

.selector-group {
    flex: 1;
    min-width: 250px;
    text-align: left;
}

.selector-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 16px;
}

.selector-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.selector-group select:disabled {
    background-color: var(--selector-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.selector-instructions {
    margin-top: 15px;
    font-size: 16px;
    color: var(--text-color);
    text-align: center;
}

button {
    padding: 10px 20px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
}

button:hover {
    background-color: var(--button-hover);
    transform: scale(1.05);
}

button:disabled {
    background-color: var(--button-disabled);
    cursor: not-allowed;
    transform: none;
}

/* Reverse toggle button in header */
.reverse-toggle-header {
    background: var(--card-bg);
    border: 2px solid var(--card-border);
    color: var(--text-color);
    padding: 10px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.reverse-toggle-header:hover:not(:disabled) {
    background: var(--selector-bg);
    transform: scale(1.05);
}

.reverse-toggle-header:active {
    transform: scale(0.95);
}

.reverse-toggle-header:disabled {
    background: var(--selector-bg);
    cursor: not-allowed;
    opacity: 0.6;
}

.reverse-toggle-header.active {
    background: var(--button-bg);
    color: white;
    border-color: var(--button-bg);
}

.reverse-toggle-header.active:hover:not(:disabled) {
    background: var(--button-hover);
    border-color: var(--button-hover);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    h1 {
        font-size: 24px;
        margin-bottom: 15px;
    }
    
    .selector-instructions {
        font-size: 14px;
        margin-top: 10px;
    }
    
    .flashcard {
        height: 250px;
    }
    
    .card-content {
        font-size: 20px;
        padding: 15px;
    }
    
    .card-controls-overlay {
        padding: 10px;
    }
    
    .center-controls {
        bottom: 10px;
    }
    
    .nav-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .language-dropdown {
        right: -10px;
        min-width: 180px;
        max-height: 250px;
    }
    
    .language-option {
        padding: 10px 12px;
    }
    
    .language-toggle {
        min-width: 50px;
        padding: 6px 10px;
        font-size: 13px;
    }
}
/* Notification System Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    max-width: 400px;
    min-width: 300px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--card-shadow);
    z-index: 10000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.notification-show {
    opacity: 1;
    transform: translateX(0);
}

.notification-hide {
    opacity: 0;
    transform: translateX(100%);
}

.notification-content {
    display: flex;
    align-items: flex-start;
    padding: 16px;
    gap: 12px;
}

.notification-icon {
    font-size: 18px;
    margin-top: 2px;
    flex-shrink: 0;
}

.notification-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-line;
    color: var(--text-color);
}

.notification-close {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.notification-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
    transform: none;
}

[data-theme="dark"] .notification-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.notification-close i {
    font-size: 12px;
}

/* Notification type styles */
.notification-info {
    border-left: 4px solid #007bff;
}

.notification-info .notification-icon {
    color: #007bff;
}

.notification-success {
    border-left: 4px solid var(--success-color);
}

.notification-success .notification-icon {
    color: var(--success-color);
}

.notification-warning {
    border-left: 4px solid var(--warning-color);
}

.notification-warning .notification-icon {
    color: var(--warning-color);
}

.notification-error {
    border-left: 4px solid var(--error-color);
}

.notification-error .notification-icon {
    color: var(--error-color);
}

/* Feature unavailable button styles */
.feature-unavailable {
    opacity: 0.5;
    position: relative;
}

.feature-unavailable::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 70%;
    background-color: var(--error-color);
    transform: translate(-50%, -50%) rotate(45deg);
    pointer-events: none;
}

/* Mobile notification adjustments */
@media (max-width: 768px) {
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        min-width: auto;
    }
    
    .notification-content {
        padding: 12px;
        gap: 10px;
    }
    
    .notification-message {
        font-size: 13px;
    }
    
    .notification-icon {
        font-size: 16px;
    }
}

/* Stack multiple notifications */
.notification:nth-child(n+2) {
    margin-top: 10px;
}

/* Animation for stacked notifications */
.notification:not(:first-child) {
    animation-delay: 0.1s;
}