:root {
    --primary: #f97316;
    /* Ylsoo Orange */
    --primary-hover: #ea580c;
    --bg-body: #ffffff;
    --bg-surface: #ffffff;
    --text-main: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: #fafafa;
    /* Very light gray for contrast with white cards */
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

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

header h1 {
    font-weight: 800;
    /* Bolder for premium feel */
    font-size: 2.25rem;
    color: #111827;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

header p {
    color: var(--text-secondary);
    font-size: 1.125rem;
    max-width: 600px;
    margin: 0 auto;
}

.translation-form {
    background: var(--bg-surface);
    padding: 3rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.03);
    /* Subtle border */
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1.5rem;
    background: #fff;
    padding: 0;
}

.select-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    position: relative;
}

label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    /* Custom chevron */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1em 1em;
    /* size */
}

select:hover {
    border-color: #d1d5db;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
    /* Orange ring */
}

.swap-btn {
    background: #fff;
    border: 1px solid var(--border);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    margin-top: 1.4rem;
    flex-shrink: 0;
}

.swap-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
    background-color: #fff7ed;
    /* Light orange tint */
}

/* Text Areas */
.text-area-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    /* Removing gap for seamless look or keeping it? Let's use a gap with border logic */
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 2rem;
    min-height: 250px;
}

.input-group,
.output-group {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 1.5rem;
    background: #fff;
}

.input-group {
    border-right: 1px solid var(--border);
}

.output-group {
    background-color: #f9fafb;
    /* Slight grey for output to distinguish */
}

textarea {
    width: 100%;
    height: 100%;
    border: none;
    resize: none;
    font-family: inherit;
    font-size: 1.25rem;
    /* Larger text */
    line-height: 1.6;
    color: var(--text-main);
    background: transparent;
    padding: 0;
}

textarea:focus {
    outline: none;
}

textarea::placeholder {
    color: #d1d5db;
}

.translation-result {
    font-size: 1.25rem;
    line-height: 1.6;
    color: var(--text-main);
    white-space: pre-wrap;
}

.placeholder-text {
    color: #9ca3af;
    font-weight: 400;
}

.error-message {
    color: #ef4444;
    background: #fee2e2;
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
}

/* Actions */
.actions {
    display: flex;
    justify-content: flex-end;
}

.translate-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 100px;
    /* Pill shape */
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3);
}

.translate-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(249, 115, 22, 0.4);
}

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

.translate-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Login Button */
.login-btn {
    background-color: var(--primary);
    color: white;
    padding: 0.5rem 1.25rem;
    border-radius: 100px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    display: inline-block;
}

.login-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(249, 115, 22, 0.3);
}

.signup-link {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.signup-link:hover {
    color: var(--primary);
}

/* Profile Icon */
.profile-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-icon:hover {
    border-color: var(--primary);
}

.profile-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #f3f4f6;
    /* Gray-100 */
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    border: 2px solid var(--border);
    cursor: pointer;
}

/* Copy Button styles from JS are inline, but let's add class support if needed */
.copy-btn {
    opacity: 0.6;
}

.copy-btn:hover {
    opacity: 1;
    background-color: #e5e7eb;
}

@media (max-width: 768px) {
    .text-area-container {
        grid-template-columns: 1fr;
        border-radius: var(--radius);
        border: 1px solid var(--border);
    }

    .input-group {
        border-right: none;
        border-bottom: 1px solid var(--border);
        min-height: 200px;
    }

    .output-group {
        min-height: 200px;
    }

    .translation-form {
        padding: 1.5rem;
    }

    .controls {
        flex-direction: column;
        gap: 0.5rem;
    }

    .swap-btn {
        margin-top: 0;
        transform: rotate(90deg);
    }

    .swap-btn:hover {
        transform: rotate(270deg);
    }

    .swap-btn:hover {
        transform: rotate(270deg);
    }
}

/* Auth Pages Styling */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    width: 100%;
}

.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border: 1px solid var(--border);
}

.auth-card h1 {
    margin-bottom: 2rem;
    color: var(--text-main);
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.9rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.1);
}

.auth-btn {
    width: 100%;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 100px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 1rem;
    margin-bottom: 1.5rem;
}

.auth-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(249, 115, 22, 0.3);
}

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

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.back-link {
    display: block;
    margin-top: 2rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
}

.back-link:hover {
    color: var(--text-main);
}

/* Auth Dropdown Styles */
.user-menu-container {
    position: relative;
    display: inline-block;
    height: 100%;
}

.user-profile-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: 20px;
    transition: background-color 0.2s;
    user-select: none;
}

.user-profile-trigger:hover {
    background-color: #f3f4f6;
}

.user-email-display {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background-color: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
    animation: fadeIn 0.15s ease-out;
}

.user-menu-container:hover .user-dropdown-menu {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 16px;
    color: var(--text-main);
    text-decoration: none;
    font-size: 0.9rem;
    border: none;
    background: none;
    cursor: pointer;
    transition: background-color 0.15s;
}

.dropdown-item:hover {
    background-color: #f9fafb;
    color: var(--primary);
}

.dropdown-divider {
    height: 1px;
    background-color: var(--border);
    margin: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

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

/* --- Camera Lens Feature --- */
.lens-body {
    background: #000;
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
}

.lens-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

#camera-feed {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    object-fit: cover;
    z-index: 1;
}

.lens-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.lens-header {
    display: flex;
    align-items: center;
    padding: 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
    gap: 15px;
}

.back-btn {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.lens-controls {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 100px;
    backdrop-filter: blur(10px);
    width: fit-content;
    margin: 0 auto;
}

.lens-controls select {
    background: transparent;
    border: none;
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 5px;
    width: auto;
    /* override previous select width */
    appearance: none;
    background-image: none;
    cursor: pointer;
    text-align: center;
    text-align-last: center;
}

.lens-controls select:focus {
    box-shadow: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.lens-controls select option {
    color: black;
    background: white;
}

.arrow {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
}

.scan-overlay {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scan-line {
    width: 80%;
    height: 2px;
    background: rgba(249, 115, 22, 0.8);
    box-shadow: 0 0 10px var(--primary);
    position: relative;
    animation: scanAnimation 3s infinite linear;
}

@keyframes scanAnimation {
    0% {
        top: -30%;
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        top: 30%;
        opacity: 0;
    }
}

.lens-footer {
    display: flex;
    justify-content: center;
    padding-bottom: 50px;
    padding-top: 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, transparent 100%);
}

.capture-trigger {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.1s;
}

.capture-trigger:active {
    transform: scale(0.95);
}

.capture-trigger .inner-circle {
    width: 66px;
    height: 66px;
    background: white;
    border-radius: 50%;
    transition: all 0.2s;
}

.capture-trigger:hover .inner-circle {
    background: var(--primary);
}

/* Modal */
.lens-result-modal {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: auto;
    max-height: 80%;
    background: white;
    z-index: 20;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateY(0);
}

.lens-result-modal.hidden {
    transform: translateY(100%);
}

.result-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.handle-bar {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.result-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
}

.close-btn {
    background: none;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: var(--text-secondary);
}

.text-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
    max-height: 300px;
}

/* Real-time Lens Overlays */
.overlay-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let touches pass through to video/controls */
    overflow: hidden;
    z-index: 5;
}

.translation-bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
    z-index: 10;
    transform-origin: top left;
    transition: all 0.2s ease-out;
    border: 1px solid var(--primary);
    pointer-events: auto;
    /* Allow clicking bubbles if we want interaction later */
}

.pause-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid white;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    cursor: pointer;
    transition: all 0.2s;
}

/* Active state for pause button (e.g. when paused) */
.pause-btn.paused {
    background: white;
    color: var(--primary);
}

.source-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid var(--border);
}

.divider {
    height: 1px;
    background: var(--border);
    width: 100%;
}

.translated-text {
    font-size: 1.2rem;
    color: var(--text-main);
    font-weight: 500;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.spinner.hidden {
    display: none;
}

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

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


.input-tool-btn {
    position: absolute;
    bottom: 15px;
    right: 15px;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}


.input-tool-btn:hover {
    background: #f3f4f6;
    color: var(--primary);
}

/* Translation Bubble - Premium UI */
.translation-bubble {
    position: absolute;
    background: rgba(255, 255, 255, 0.85);
    /* Slightly more opaque for readability */
    color: #1f2937;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.05);
    /* Premium shadow */
    backdrop-filter: blur(12px);
    /* Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    z-index: 100;
    transform: translate(-50%, -100%);
    /* Center above the target point roughly */
    white-space: nowrap;
    animation: bubblePop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transform-origin: bottom center;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
}

@keyframes bubblePop {
    0% {
        opacity: 0;
        transform: translate(-50%, -90%) scale(0.8);
    }

    100% {
        opacity: 1;
        transform: translate(-50%, -100%) scale(1);
    }
}