/* PolyTalk Brand Colors */
:root {
    /* Orange - Poly (Input/Speak side) */
    --poly-primary: #FF7A18;
    --poly-secondary: #FFA726;

    /* Blue - Talk (Output/Receive side) */
    --talk-primary: #1E88E5;
    --talk-secondary: #0D47A1;

    /* Dark background */
    --bg-dark: #1a1a2e;
    --bg-card: #16213e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-dark);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 25px;
    position: relative;
}

.header-right {
    position: absolute;
    top: 10px;
    right: 10px;
}

.settings-toggle {
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--talk-primary) 100%);
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 122, 24, 0.3);
}

.settings-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(255, 122, 24, 0.4);
}

.settings-top-right {
    position: absolute;
    top: -20px;
    right: 0;
    z-index: 10;
}

.settings-icon {
    font-size: 1.2rem;
    color: white;
}

.settings-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.settings-modal.active {
    display: flex;
}

.settings-content {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.settings-header h2 {
    color: white;
    font-size: 1.5rem;
    margin: 0;
}

.close-settings {
    background: none;
    border: none;
    font-size: 2rem;
    color: #a0a0a0;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-settings:hover {
    color: white;
}

.settings-body {
    color: white;
}

.settings-section {
    margin-bottom: 25px;
}

.settings-section h3 {
    font-size: 1.1rem;
    color: var(--poly-primary);
    margin-bottom: 15px;
}

.settings-field {
    margin-bottom: 10px;
}

.settings-field label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
}

.settings-field select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 122, 24, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(22, 33, 62, 0.8);
    color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.settings-field select:focus {
    outline: none;
    border-color: var(--poly-primary);
}

.settings-note {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-top: 8px;
    font-style: italic;
}

.settings-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: flex-end;
}

.btn-save {
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--poly-secondary) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 122, 24, 0.4);
}

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

.logo-container {
    margin-bottom: 0px;
}

.app-logo {
    width: 130px;
    height: 130px;
    object-fit: contain;
    filter: drop-shadow(0 4px 20px rgba(255, 122, 24, 0.3));
}

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--talk-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    color: #a0a0a0;
}

main {
    background: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    align-items: center;
    position: relative;
}

.controls .language-select {
    flex: 1;
    min-width: 200px;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.controls .language-select label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.controls .language-select select,
.language-select select {
    width: 100%;
    padding: 10px 16px;
    border: 2px solid rgba(255, 122, 24, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(22, 33, 62, 0.8);
    color: white;
    cursor: pointer;
    transition: border-color 0.2s;
    height: 42px;
}

.controls .language-select select:focus,
.language-select select:focus {
    outline: none;
    border-color: var(--poly-primary);
}

.controls .language-select-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex: 1;
    height: 46px;
}

.controls .language-select-wrapper .settings-toggle {
    display: none;
}

.controls .language-select-wrapper .settings-toggle:hover {
    transform: none;
}

.controls .btn-swap {
    flex: 0 0 50px;
    padding: 12px;
    min-width: 50px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-top: 24px;
}

.controls .microphone-select {
    flex: 1;
    min-width: 200px;
    max-width: 100%;
}

.recording-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.controls .language-select,
.controls [name="microphone"] {
    flex: 1;
    min-width: 200px;
}

.external-audio {
    margin-bottom: 25px;
}

.url-input-group {
    display: flex;
    gap: 10px;
}

.url-input-group input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.url-input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-url {
    background: #667eea;
    color: white;
}

.btn-url:hover:not(:disabled) {
    background: #5568d3;
}

.language-select label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
}

.language-select select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 122, 24, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(22, 33, 62, 0.8);
    color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.language-select select:focus {
    outline: none;
    border-color: var(--poly-primary);
}

.microphone-select {
    width: 100%;
}

.microphone-select label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #e0e0e0;
}

.microphone-select select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid rgba(255, 122, 24, 0.3);
    border-radius: 8px;
    font-size: 1rem;
    background: rgba(22, 33, 62, 0.8);
    color: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.microphone-select select:focus {
    outline: none;
    border-color: var(--poly-primary);
}

.recording-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 15px;
}

.session-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

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

.btn-record {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-record:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(245, 87, 108, 0.4);
}

.btn-tertiary {
    background: #fff3e0;
    color: #ef6c00;
    padding: 10px 20px;
    font-size: 0.9rem;
    border: 1px solid #ffe0b2;
    font-weight: 600;
    transform: none;
    box-shadow: none;
    width: 120px;
}

.btn-tertiary:hover:not(:disabled) {
    background: #ffe0b2;
}

.btn-stop {
    background: #ffebee;
    color: #d32f2f;
    padding: 10px 20px;
    font-size: 0.9rem;
    border: 1px solid #ffcdd2;
    font-weight: 600;
    width: 120px;
}

.btn-stop:hover:not(:disabled) {
    background: #ffcdd2;
    color: #b71c1c;
    transform: none;
    box-shadow: none;
}

.btn-resume {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 10px 20px;
    font-size: 0.9rem;
    border: 1px solid #c8e6c9;
    font-weight: 600;
    transform: none;
    box-shadow: none;
    width: 120px;
}

.btn-resume:hover:not(:disabled) {
    background: #c8e6c9;
}

.btn-process {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-process:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-live {
    background: linear-gradient(225deg, var(--poly-primary) 0%, var(--talk-primary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 122, 24, 0.3);
}

.btn-live:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(255, 122, 24, 0.5);
}

.btn-share {
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--talk-primary) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 122, 24, 0.3);
}

.btn-share:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(255, 122, 24, 0.5);
}

.btn-icon {
    font-size: 1.3rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.5));
}

.btn-text {
    display: inline-block;
    line-height: 1.2;
    vertical-align: middle;
}

.btn-swap {
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--talk-primary) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-swap:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 5px 20px rgba(255, 122, 24, 0.4);
}

.btn-swap .btn-icon {
    font-size: 1.5rem;
}

.permission-request {
    text-align: center;
    margin: 20px 0;
}

.btn-permission {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.btn-permission:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(17, 153, 142, 0.4);
}

.status {
    text-align: center;
    padding: 12px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
    display: none;
}

.status.visible {
    display: block;
}

.status.info {
    background: rgba(30, 136, 229, 0.2);
    color: #64b5f6;
    border: 1px solid rgba(30, 136, 229, 0.3);
}

.status.success {
    background: rgba(76, 175, 80, 0.2);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.status.error {
    background: rgba(244, 67, 54, 0.2);
    color: #e57373;
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.status.warning {
    background: rgba(255, 152, 0, 0.2);
    color: #ffb74d;
    border: 1px solid rgba(255, 152, 0, 0.3);
}

.recording-indicator {
    display: none;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: linear-gradient(135deg, var(--poly-primary) 0%, var(--poly-secondary) 100%);
    color: white;
    border-radius: 50px;
    margin-bottom: 20px;
    animation: pulse 1.5s infinite;
    box-shadow: 0 4px 15px rgba(255, 122, 24, 0.4);
    position: relative;
    overflow: hidden;
}

.recording-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.recording-indicator.visible {
    display: flex;
}

.recording-dot {
    width: 12px;
    height: 12px;
    background: #ff4757;
    border-radius: 50%;
    animation: blink 1.2s ease-in-out infinite, dot-pulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.6);
}

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

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

@keyframes dot-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
}

.live-results {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

.live-box {
    border-radius: 12px;
    padding: 20px;
}

.live-box.transcript-box {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03) 0%, rgba(255, 255, 255, 0.05) 100%);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.live-box.translation-box {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.25) 100%);
    border: 2px solid rgba(102, 126, 234, 0.5);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3), 0 0 15px rgba(102, 126, 234, 0.15);
}

.live-box h3 {
    font-size: 1rem;
    color: var(--poly-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-content {
    min-height: 60px;
    font-size: 1.1rem;
    line-height: 1.6;
    font-weight: 500;
}

.transcript-box .live-content {
    color: #e0e0e0;
}

.translation-box .live-content {
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.results {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.result-box {
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.1) 0%, rgba(13, 71, 161, 0.15) 100%);
    border: 2px solid rgba(30, 136, 229, 0.3);
    border-radius: 12px;
    padding: 20px;
}

.result-box h3 {
    font-size: 1rem;
    color: var(--talk-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-content {
    min-height: 60px;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #e0e0e0;
}

.live-box h3 {
    font-size: 1rem;
    color: var(--poly-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.placeholder {
    color: #a0a0a0;
    font-style: italic;
}

.audio-container {
    background: linear-gradient(135deg, rgba(30, 136, 229, 0.1) 0%, rgba(13, 71, 161, 0.15) 100%);
    border: 2px solid rgba(30, 136, 229, 0.3);
    border-radius: 12px;
    padding: 30px 20px;
}

.audio-container h3 {
    font-size: 1rem;
    color: var(--talk-primary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#audio-player {
    width: 100%;
    max-width: 400px;
}

#audio-player audio {
    width: 100%;
}

footer {
    text-align: center;
    color: white;
    margin-top: 30px;
    opacity: 0.8;
    font-size: 0.9rem;
}

footer p {
    margin: 4px 0;
}

footer a {
    color: #AAAAAA;
    text-decoration: none;
    transition: color 0.2s;
}

footer a:hover {
    color: #FFFFFF;
    text-decoration: underline;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header {
        margin-bottom: 10px;
    }

    .logo-container {
        margin-bottom: 0px;
    }

    .app-logo {
        width: 100px;
        height: 100px;
    }

    header h1 {
        font-size: 1.8rem;
        margin-bottom: 6px;
    }

    main {
        position: relative;
    }

    .controls {
        flex-direction: column;
        gap: 15px;
    }

    .controls .language-select,
    .controls .microphone-select {
        width: 100%;
        max-width: 100%;
    }

    .controls .language-select-wrapper {
        width: 100%;
    }

    .controls .btn-swap {
        width: 50px;
        height: 46px;
        transform: none;
        margin-top: 0;
    }

    .controls .btn-swap .btn-icon {
        font-size: 1.5rem;
        transform: rotate(90deg);
    }

    .controls .btn-swap:hover {
        transform: scale(1.1) rotate(180deg);
        box-shadow: 0 5px 20px rgba(255, 122, 24, 0.4);
    }

    .status {
        display: block !important;
        margin-bottom: 15px;
        padding: 10px;
        font-size: 0.9rem;
    }

    .recording-controls {
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 12px;
    }

    .session-controls {
        flex-wrap: wrap;
    }

    .btn {
        flex: 1 1 100%;
        min-width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 0.95rem;
    }

    .btn-icon {
        font-size: 1.2rem;
    }

    .recording-indicator {
        font-size: 0.9rem;
        padding: 12px;
    }

    .tab-audio-note {
        text-align: center;
        font-size: 0.85rem;
        color: #ffa726;
        margin-top: 8px;
        margin-bottom: 10px;
        padding: 0 10px;
        font-weight: 500;
    }

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

/* Language swap separator */
.language-swap-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    padding: 10px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.language-swap-separator .swap-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(102, 126, 234, 0.6), transparent);
}

.language-swap-separator .swap-text {
    margin: 0 15px;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    white-space: nowrap;
}
