/**
 * Saigon Translator - Premium Edition Styles
 * 탭 기반 UI, 확장된 창 크기, 프리미엄 UX
 */

/* ================================
   Floating Button
   ================================ */
#saigon-translator-btn {
    position: fixed;
    bottom: 92px;
    left: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FF4B2B 0%, #FF416C 100%);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(255, 75, 43, 0.45);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: st-pulse-glow 2s infinite;
}

#saigon-translator-btn::after {
    content: 'AI 번역';
    position: absolute;
    top: -28px;
    left: 50%;
    transform: translateX(-50%);
    background: #FF416C;
    color: white;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 10px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

@keyframes st-pulse-glow {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 75, 43, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(255, 75, 43, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(255, 75, 43, 0);
    }
}

#saigon-translator-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(235, 82, 68, 0.5);
}

#saigon-translator-btn.active {
    background: linear-gradient(135deg, #D93D30 0%, #B22A1F 100%);
    transform: rotate(45deg);
}

#saigon-translator-btn svg {
    width: 26px;
    height: 26px;
    transition: transform 0.3s;
}

/* ================================
   Main Panel
   ================================ */
#saigon-translator-panel {
    position: fixed;
    bottom: 180px;
    left: 20px;
    width: 420px;
    max-height: calc(100vh - 220px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 60px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#saigon-translator-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ================================
   Header
   ================================ */
.st-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #EB5244 0%, #D93D30 100%);
    color: white;
}

.st-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.st-logo {
    font-size: 24px;
}

.st-header-text h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.st-subtitle {
    font-size: 11px;
    opacity: 0.85;
}

.st-header-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.st-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.st-icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

.st-icon-btn svg {
    width: 16px;
    height: 16px;
}

.st-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    transition: background 0.2s;
}

.st-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* ================================
   Tab Navigation
   ================================ */
.st-tabs {
    display: flex;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 0 8px;
}

.st-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    background: none;
    border: none;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all 0.2s;
}

.st-tab svg {
    width: 20px;
    height: 20px;
}

.st-tab:hover {
    color: #EB5244;
}

.st-tab.active {
    color: #EB5244;
}

.st-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: #EB5244;
    border-radius: 3px 3px 0 0;
}

/* ================================
   Tab Content
   ================================ */
.st-content {
    flex: 1;
    overflow-y: auto;
}

.st-tab-content {
    display: none;
    padding: 0;
}

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

/* ================================
   Voice Tab
   ================================ */
.st-voice-section {
    padding: 20px;
}

.st-voice-card {
    background: linear-gradient(180deg, #fef2f2 0%, #fff 100%);
    border-radius: 16px;
    padding: 24px;
    text-align: center;
    border: 1px solid #fecaca;
}

.st-voice-btn {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: linear-gradient(135deg, #EB5244 0%, #D93D30 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    box-shadow: 0 6px 24px rgba(235, 82, 68, 0.4);
    transition: all 0.3s;
}

.st-voice-btn svg {
    width: 40px;
    height: 40px;
}

.st-voice-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 28px rgba(235, 82, 68, 0.5);
}

.st-voice-btn.recording {
    animation: pulse-recording 1.5s infinite;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

@keyframes pulse-recording {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.6);
    }

    50% {
        box-shadow: 0 0 0 24px rgba(239, 68, 68, 0);
    }
}

/* Waveform */
.st-waveform {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 50px;
    margin: 16px 0;
}

.st-waveform.active {
    display: flex;
}

.st-waveform span {
    width: 4px;
    height: 12px;
    background: linear-gradient(180deg, #EB5244 0%, #f87171 100%);
    border-radius: 2px;
    animation: wave 0.6s ease-in-out infinite;
}

.st-waveform span:nth-child(1) {
    animation-delay: 0s;
}

.st-waveform span:nth-child(2) {
    animation-delay: 0.08s;
}

.st-waveform span:nth-child(3) {
    animation-delay: 0.16s;
}

.st-waveform span:nth-child(4) {
    animation-delay: 0.24s;
}

.st-waveform span:nth-child(5) {
    animation-delay: 0.32s;
}

.st-waveform span:nth-child(6) {
    animation-delay: 0.4s;
}

.st-waveform span:nth-child(7) {
    animation-delay: 0.32s;
}

.st-waveform span:nth-child(8) {
    animation-delay: 0.24s;
}

.st-waveform span:nth-child(9) {
    animation-delay: 0.16s;
}

.st-waveform span:nth-child(10) {
    animation-delay: 0.08s;
}

.st-waveform span:nth-child(11) {
    animation-delay: 0s;
}

.st-waveform span:nth-child(12) {
    animation-delay: 0.08s;
}

.st-waveform span:nth-child(13) {
    animation-delay: 0.16s;
}

.st-waveform span:nth-child(14) {
    animation-delay: 0.24s;
}

.st-waveform span:nth-child(15) {
    animation-delay: 0.32s;
}

@keyframes wave {

    0%,
    100% {
        height: 12px;
        opacity: 0.5;
    }

    50% {
        height: 36px;
        opacity: 1;
    }
}

.st-voice-status {
    font-size: 15px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.st-voice-status.listening {
    color: #EB5244;
}

.st-voice-status.translating {
    color: #f59e0b;
}

.st-voice-status.speaking {
    color: #10b981;
}

.st-voice-status.error {
    color: #ef4444;
}

.st-voice-hint {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.6;
}

/* Voice Result */
.st-voice-result {
    padding: 0 16px 16px;
}

.st-result-box {
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
}

.st-result-box.translated {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
    border: 1px solid #86efac;
}

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

.st-lang-badge {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
}

.st-result-actions {
    display: flex;
    gap: 4px;
}

.st-copy-btn,
.st-speak-btn,
.st-save-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.st-copy-btn:hover,
.st-speak-btn:hover,
.st-save-btn:hover {
    background: #EB5244;
    color: white;
}

.st-copy-btn svg,
.st-speak-btn svg,
.st-save-btn svg {
    width: 14px;
    height: 14px;
}

.st-result-text {
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
    word-break: break-word;
}

/* ================================
   Text Tab
   ================================ */
.st-direction-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.st-lang-select {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.st-lang-select:hover {
    border-color: #EB5244;
}

.st-lang-select svg {
    width: 14px;
    height: 14px;
    opacity: 0.5;
}

.st-swap-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #EB5244;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.st-swap-btn svg {
    width: 18px;
    height: 18px;
}

/* Text Input */
.st-text-input-area {
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

#st-input {
    width: 100%;
    min-height: 90px;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

#st-input:focus {
    outline: none;
    border-color: #EB5244;
}

#st-input::placeholder {
    color: #94a3b8;
}

.st-input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
}

.st-char-count {
    font-size: 12px;
    color: #94a3b8;
}

.st-input-actions {
    display: flex;
    gap: 4px;
}

.st-clear-btn,
.st-paste-btn {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #f1f5f9;
    border: none;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.st-clear-btn:hover,
.st-paste-btn:hover {
    background: #e2e8f0;
    color: #374151;
}

.st-clear-btn svg,
.st-paste-btn svg {
    width: 14px;
    height: 14px;
}

/* Text Output */
.st-text-output-area {
    padding: 16px;
    min-height: 120px;
    position: relative;
}

.st-output-text {
    font-size: 14px;
    line-height: 1.6;
    color: #1e293b;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 60px;
}

.st-output-text:empty::before {
    content: '번역 결과가 여기에 표시됩니다';
    color: #94a3b8;
    font-style: italic;
}

.st-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 13px;
}

.st-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #EB5244;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.st-spinner.large {
    width: 40px;
    height: 40px;
    border-width: 4px;
}

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

.st-output-footer {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

.st-output-actions {
    display: flex;
    gap: 8px;
}

.st-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f1f5f9;
    border: none;
    border-radius: 8px;
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.st-action-btn:hover {
    background: #EB5244;
    color: white;
}

.st-action-btn svg {
    width: 14px;
    height: 14px;
}

/* ================================
   Menu Tab
   ================================ */
.st-menu-section {
    padding: 16px;
}

.st-upload-area {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 32px 20px;
    text-align: center;
    transition: all 0.2s;
}

.st-upload-area.dragover {
    border-color: #EB5244;
    background: #fef2f2;
}

.st-upload-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.st-upload-area h4 {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 700;
    color: #374151;
}

.st-upload-area p {
    margin: 0 0 16px;
    font-size: 13px;
    color: #64748b;
}

.st-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: #EB5244;
    color: white;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.st-upload-btn:hover {
    background: #D93D30;
    transform: translateY(-2px);
}

.st-upload-btn svg {
    width: 18px;
    height: 18px;
}

.st-upload-hint {
    display: block;
    margin-top: 12px;
    font-size: 11px;
    color: #94a3b8;
}

/* Image Preview */
.st-image-preview {
    position: relative;
    margin-bottom: 16px;
    border-radius: 12px;
    overflow: hidden;
}

.st-image-preview img {
    width: 100%;
    height: auto;
    display: block;
}

.st-remove-image {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu Result */
.st-menu-result {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin-top: 16px;
}

.st-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.st-menu-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #374151;
}

.st-menu-content {
    font-size: 14px;
    line-height: 1.8;
    color: #1e293b;
    white-space: pre-wrap;
}

.st-menu-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px;
    color: #64748b;
}

/* ================================
   History Panel
   ================================ */
.st-history-panel {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.st-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e2e8f0;
}

.st-history-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
}

.st-clear-history {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 12px;
    cursor: pointer;
}

.st-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.st-history-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 13px;
    padding: 40px 20px;
}

.st-history-item {
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.st-history-item:hover {
    background: #f1f5f9;
}

.st-history-item .original {
    font-size: 12px;
    color: #64748b;
    margin-bottom: 4px;
}

.st-history-item .translated {
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
}

/* ================================
   Toast Notification
   ================================ */
.st-toast {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #1e293b;
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.st-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ================================
   Mobile Responsive
   ================================ */
@media (max-width: 480px) {
    #saigon-translator-panel {
        width: calc(100vw - 24px);
        left: 12px;
        right: 12px;
        bottom: 170px;
        max-height: 75vh;
    }

    #saigon-translator-btn {
        bottom: 92px;
        left: 12px;
        width: 56px;
        height: 56px;
    }

    .st-voice-btn {
        width: 80px;
        height: 80px;
    }

    .st-voice-btn svg {
        width: 36px;
        height: 36px;
    }

    .st-tab span {
        font-size: 10px;
    }
}

/* ================================
   Dark Mode
   ================================ */
@media (prefers-color-scheme: dark) {
    #saigon-translator-panel {
        background: #1e293b;
        box-shadow: 0 12px 60px rgba(0, 0, 0, 0.5);
    }

    .st-tabs {
        background: #0f172a;
        border-color: #334155;
    }

    .st-tab {
        color: #94a3b8;
    }

    .st-tab:hover,
    .st-tab.active {
        color: #f87171;
    }

    .st-tab.active::after {
        background: #f87171;
    }

    .st-voice-card {
        background: linear-gradient(180deg, rgba(239, 68, 68, 0.1) 0%, #1e293b 100%);
        border-color: #7f1d1d;
    }

    .st-voice-status {
        color: #e2e8f0;
    }

    .st-result-box {
        background: #0f172a;
    }

    .st-result-box.translated {
        background: linear-gradient(135deg, rgba(34, 197, 94, 0.1) 0%, rgba(34, 197, 94, 0.05) 100%);
        border-color: #166534;
    }

    .st-result-text,
    .st-output-text,
    .st-menu-content {
        color: #f1f5f9;
    }

    .st-direction-bar {
        background: #0f172a;
        border-color: #334155;
    }

    .st-lang-select {
        background: #1e293b;
        border-color: #334155;
        color: #e2e8f0;
    }

    #st-input {
        background: #0f172a;
        border-color: #334155;
        color: #f1f5f9;
    }

    .st-text-input-area,
    .st-output-footer {
        border-color: #334155;
    }

    .st-action-btn {
        background: #334155;
        color: #e2e8f0;
    }

    .st-upload-area {
        background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
        border-color: #475569;
    }

    .st-upload-area h4 {
        color: #f1f5f9;
    }

    .st-menu-result {
        background: #0f172a;
    }

    .st-menu-header h4 {
        color: #f1f5f9;
    }

    .st-history-panel {
        background: #1e293b;
    }

    .st-history-header {
        border-color: #334155;
    }

    .st-history-item {
        background: #0f172a;
    }

    .st-history-item:hover {
        background: #334155;
    }

    .st-history-item .translated {
        color: #f1f5f9;
    }
}