:root {
    --primary-gradient: linear-gradient(135deg, #ef4444 0%, #fecaca 100%);
    --bg-color: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #ef4444;
    --success-color: #10b981;
    --glass-border: rgba(239, 68, 68, 0.1);
    --glass-shadow: 0 10px 25px -5px rgba(239, 68, 68, 0.1), 0 8px 10px -6px rgba(239, 68, 68, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Background Animations */
.background-blobs {
    position: absolute;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #fee2e2;
    top: -10%;
    left: -10%;
}

.blob-2 {
    width: 350px;
    height: 350px;
    background: #fecaca;
    bottom: -10%;
    right: -10%;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: #ef4444;
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0) scale(1); }
    to { transform: translate(100px, 50px) scale(1.1); }
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 500px;
    padding: 2rem;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: var(--glass-shadow);
    text-align: center;
    z-index: 1;
}

header {
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    letter-spacing: -0.5px;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Language Selection */
.language-selection {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.select-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    flex: 1;
}

.select-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding-left: 4px;
}

.select-group select {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C2.185 5.355 2.403 5 2.808 5h10.384a.43.43 0 0 1 .33.659l-4.796 5.48a.43.43 0 0 1-.679 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 10px) center;
}

.select-group select:focus {
    border-color: var(--accent-color);
    background-color: white;
}

.swap-btn {
    margin-top: 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.swap-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: rotate(180deg);
}

.lang-label {
    font-weight: 500;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.lang-label.active {
    color: var(--text-primary);
}

/* Tabs */
.app-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(239, 68, 68, 0.05);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.2);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

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

/* Text Translator Styles */
.text-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

#manual-text-input {
    width: 100%;
    min-height: 100px;
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-primary);
    font-size: 1rem;
    resize: vertical;
    outline: none;
    transition: border-color 0.3s;
}

#manual-text-input:focus {
    border-color: var(--accent-color);
}

.translate-btn {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.8rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.translate-btn:hover {
    opacity: 0.9;
}

/* Video & Subtitles */
.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror effect */
}

.subtitle-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem 1.5rem 1.5rem;
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
    display: flex;
    justify-content: center;
    transition: opacity 0.3s;
}

#subtitle-text {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    font-size: 1.25rem;
    font-weight: 500;
    text-align: center;
    max-width: 90%;
}

.camera-status {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.5);
    padding: 8px;
    border-radius: 50%;
    line-height: 1;
}

.voice-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.camera-btn {
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
}

.camera-btn.active {
    background: var(--primary-gradient);
    color: white;
}

/* Record Button override */
.record-btn {
    position: relative;
    background: var(--primary-gradient);
    border: none;
    color: white;
    padding: 1rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0; /* Removed auto margin for flex container */
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.4);
}

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

.record-btn.listening {
    background: #ef4444;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.pulse-ring {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    border-radius: 50px;
    border: 2px solid #ef4444;
    animation: pulse 1.5s infinite;
}

.record-btn.listening .pulse-ring {
    display: block;
}

@keyframes pulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; }
}

/* Translation Displays */
.translation-display {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card {
    background: white;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem;
    text-align: left;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    font-weight: 600;
}

.badge.secondary {
    background: rgba(239, 68, 68, 0.05);
    color: #ef4444;
    opacity: 0.8;
}

#source-lang-indicator, #target-lang-indicator {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.text-content {
    font-size: 1.1rem;
    line-height: 1.5;
    min-height: 3rem;
    display: flex;
    align-items: center;
}

.placeholder {
    color: #475569;
    font-style: italic;
    font-size: 1rem;
}

.arrow-down {
    color: var(--text-secondary);
    display: flex;
    justify-content: center;
    opacity: 0.5;
}

/* History Styles */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 4px;
}

.history-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.clear-btn {
    background: transparent;
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: #fb7185;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.clear-btn:hover {
    background: rgba(244, 63, 94, 0.1);
    border-color: #f43f5e;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 8px;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 4px;
}

.history-item {
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    animation: fadeIn 0.3s ease;
}

.history-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.history-text {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-source {
    color: var(--text-primary);
    font-size: 0.95rem;
}

.history-target {
    color: var(--accent-color);
    font-size: 1rem;
    font-weight: 500;
}

.empty-history {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Footer */
footer {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #475569;
}

.dot.online { background: var(--success-color); }
.dot.busy { background: #f59e0b; }
.dot.error { background: #ef4444; }
