@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600&family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-color: #f8f9fa;
    --surface-color: rgba(255, 255, 255, 0.95);
    --surface-variant: rgba(255, 255, 255, 0.85);
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --border-color: rgba(0, 0, 0, 0.08);
    --accent-color: #202124;
    --accent-hover: #000000;
    --input-bg: rgba(0, 0, 0, 0.04);
    --error-color: #ea4335;
    --success-color: #34a853;
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #fafbfe;
    background-image: 
        radial-gradient(at 80% 0%, hsla(228,100%,96%,1) 0px, transparent 50%),
        radial-gradient(at 0% 50%, hsla(210,100%,97%,1) 0px, transparent 50%),
        radial-gradient(at 80% 100%, hsla(240,100%,97%,1) 0px, transparent 50%),
        radial-gradient(at 0% 0%, hsla(200,100%,96%,1) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 4rem 2rem;
    -webkit-font-smoothing: antialiased;
}

/* Layout */
.container {
    width: 100%;
    max-width: 680px;
}

header {
    margin-bottom: 3rem;
    text-align: center;
}

.flag-banner {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 8px 24px 8px 12px;
    border-radius: 9999px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.waving-flag {
    width: 60px;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    animation: wave-flag 2.5s infinite ease-in-out;
    transform-origin: left center;
}

@keyframes wave-flag {
    0% { transform: perspective(400px) rotateY(-10deg) skewY(1deg); }
    50% { transform: perspective(400px) rotateY(15deg) skewY(-2deg); }
    100% { transform: perspective(400px) rotateY(-10deg) skewY(1deg); }
}

.bounce-anim {
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.header-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #ccc;
    transition: all 0.3s ease;
    margin-top: -8px; /* Visually center with heading text */
    animation: cute-breathe 2.5s infinite ease-in-out;
}

@keyframes cute-breathe {
    0%, 100% { 
        transform: scale(0.8); 
        opacity: 0.6; 
    }
    50% { 
        transform: scale(1.15); 
        opacity: 1; 
    }
}

.status-online {
    background-color: var(--success-color);
    box-shadow: 0 0 0 4px rgba(30, 142, 62, 0.2);
}

.status-offline {
    background-color: var(--error-color);
    box-shadow: 0 0 0 4px rgba(217, 48, 37, 0.2);
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -0.05em;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 400;
}

/* Glassmorphism minimal panel */
.minimal-panel {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -1px 0 rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.minimal-panel:hover {
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Input Section */
.input-section form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 480px) {
    .input-section form {
        flex-direction: row;
    }
}

input {
    flex: 1;
    background: var(--input-bg);
    border: none;
    border-radius: 9999px; /* Pill shape */
    padding: 1.25rem 2rem;
    color: var(--text-primary);
    font-size: 1.1rem;
    outline: none;
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

input::placeholder {
    color: rgba(0, 0, 0, 0.4);
    font-weight: 400;
}

input:focus {
    background: var(--surface-color);
    border-color: var(--accent-color);
}

button {
    background: var(--accent-color);
    color: #ffffff;
    border: none;
    border-radius: 9999px;
    padding: 1.25rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(255, 255, 255, 0.25);
}

button:active {
    background: #174ea6;
    box-shadow: none;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

/* Offline state styling */
.anki-offline input {
    background: rgba(127, 127, 127, 0.1);
    color: rgba(0, 0, 0, 0.5);
    cursor: not-allowed;
    border-color: transparent;
}

.anki-offline input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

.anki-offline button#generateBtn {
    background: #d1d5db;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.8;
}

#statusMessage {
    margin-top: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    font-family: 'Outfit', sans-serif;
}

.success { color: var(--success-color); }
.error { color: var(--error-color); }
.hidden { display: none !important; }

.show-status {
    animation: slideUpFadeIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.hide-status {
    animation: fadeOutDown 0.4s ease forwards;
}

@keyframes slideUpFadeIn {
    0% { transform: translateY(10px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

@keyframes fadeOutDown {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(10px); opacity: 0; }
}

/* Activity Log */
.progress-container {
    width: 100%;
    margin-top: 1.5rem;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.02);
    animation: popIn 0.3s ease;
    text-align: left;
}

.activity-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,0.05);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: #34a853;
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(52, 168, 83, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 168, 83, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(52, 168, 83, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(52, 168, 83, 0); }
}

.activity-log {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 120px;
    overflow-y: hidden;
}

.activity-item {
    font-size: 0.95rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    transform: translateY(10px);
    animation: slideUpFade 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.activity-item.completed {
    color: var(--text-secondary);
}

.activity-item.completed::before {
    content: "✓";
    color: #34a853;
    font-weight: bold;
}

.activity-item.loading::before {
    content: "⟳";
    color: var(--accent-color);
    display: inline-block;
    animation: spin 1.5s linear infinite;
}

@keyframes slideUpFade {
    to { opacity: 1; transform: translateY(0); }
}

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

/* Preview Section */
.preview-section {
    margin-top: 4rem;
    animation: fadeIn 0.4s ease-out;
}

.preview-section h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
    text-align: center;
}

.card-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card-side {
    position: relative;
    padding: 2rem;
    padding-top: 3rem;
    background: var(--surface-color);
}

.side-label {
    position: absolute;
    top: 1rem;
    left: 1.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

/* Anki Content Overrides */
.html-content {
    background: var(--surface-color); /* Match card */
    border-radius: 12px;
}

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

/* Duplicate Error Animation */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-5px); }
    40%, 80% { transform: translateX(5px); }
}

.error-shake {
    animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
    background: #fce8e6 !important;
    border-color: transparent !important;
}

/* Audio Controls */
.audio-controls {
    margin-top: 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.play-audio-btn {
    background: var(--surface-variant);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    min-width: 0;
    box-shadow: none;
}

.play-audio-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

.play-audio-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* Settings Panel */
.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px;
    min-width: auto;
    border-radius: 50%;
    transition: background 0.2s;
    box-shadow: none;
}

.icon-btn:hover {
    background: var(--input-bg);
    box-shadow: none;
}

.settings-corner-btn {
    position: fixed;
    top: 24px;
    right: 24px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-color);
    border: none;
    border-radius: 9999px;
    padding: 12px 24px;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.settings-corner-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.settings-panel {
    margin-bottom: 2rem;
}

.settings-panel h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 480px) {
    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.setting-group.full-width {
    grid-column: 1 / -1;
}

textarea {
    width: 100%;
    border: none;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.4;
    padding: 1rem;
    border-radius: 12px;
    resize: vertical;
    outline: none;
    transition: background 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

textarea:focus {
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.setting-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.setting-group select, .setting-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    background-color: var(--input-bg);
    color: var(--text-primary);
    transition: all 0.2s;
}

.setting-group select:focus, .setting-group input:focus {
    border-color: var(--accent-color);
    outline: none;
    background-color: rgba(255, 255, 255, 0.05);
}

.setting-group select option {
    background-color: #ffffff;
    color: var(--text-primary);
}

.deck-input-group {
    display: flex;
    gap: 0.5rem;
}

.deck-input-group input, .deck-input-group select {
    border-radius: 8px;
    padding: 0.75rem 1rem;
}

.small-btn {
    min-width: 40px;
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 1rem;
}

.hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}

.blink-status {
    animation: blink 2s infinite ease-in-out;
    background: rgba(52, 168, 83, 0.1);
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(52, 168, 83, 0.3);
    display: inline-block;
}

.dropdown-arrow {
    font-size: 10px;
    margin-left: 6px;
    opacity: 0.6;
    display: inline-block;
    vertical-align: middle;
}

.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 12px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px;
    min-width: 160px;
    z-index: 100;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    gap: 4px;
    opacity: 1;
    visibility: visible;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.custom-dropdown.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(-10px);
    pointer-events: none;
}

.dropdown-item {
    padding: 10px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: left;
}

.dropdown-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: translateX(4px);
}

/* Cloud Badge Animation */
.cloud-badge {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    padding: 10px 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #e0e0e0;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2), 0 0 20px rgba(52, 168, 83, 0.2);
    animation: float 3s ease-in-out infinite;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.cloud-badge .cloud-icon {
    font-size: 18px;
    animation: pulseCloud 2s infinite;
}

.cloud-badge .sparkle-icon {
    font-size: 16px;
    color: #fbbc04;
    animation: twinkle 1.5s infinite alternate;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

@keyframes pulseCloud {
    0% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(255,255,255,0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255,255,255,0.4)); }
}

@keyframes twinkle {
    0% { opacity: 0.3; transform: scale(0.8) rotate(0deg); }
    100% { opacity: 1; transform: scale(1.2) rotate(15deg); }
}
