/* Reset e Variáveis */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --success: #10b981;
    --error: #ef4444;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-dark);
}

/* Container Principal */
.container {
    width: 100%;
    max-width: 900px;
    background: var(--card-bg);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 40px;
    backdrop-filter: blur(10px);
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo i {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
}

/* Área do Tradutor */
.translator-box {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 20px;
    align-items: stretch;
}

@media (max-width: 768px) {
    .translator-box {
        grid-template-columns: 1fr;
    }
    
    .swap-section {
        transform: rotate(90deg);
        padding: 10px 0;
    }
}

/* Seções de Input/Output */
.input-section, .output-section {
    display: flex;
    flex-direction: column;
    border: 2px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.3s;
}

.input-section:focus-within {
    border-color: var(--primary);
}

.lang-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f9fafb;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-dark);
}

.lang-header button {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: all 0.2s;
}

.lang-header button:hover {
    background: var(--border);
    color: var(--text-dark);
}

textarea {
    flex: 1;
    min-height: 150px;
    padding: 16px;
    border: none;
    resize: none;
    font-size: 1rem;
    line-height: 1.6;
    font-family: inherit;
    outline: none;
}

#output-text {
    background: #f9fafb;
    color: var(--text-dark);
}

.char-count {
    padding: 8px 16px;
    text-align: right;
    font-size: 0.85rem;
    color: var(--text-light);
    background: #f9fafb;
    border-top: 1px solid var(--border);
}

/* Output Wrapper */
.output-wrapper {
    position: relative;
    flex: 1;
    display: flex;
}

.loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Botão de Troca */
.swap-section {
    display: flex;
    align-items: center;
    justify-content: center;
}

#swap-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: white;
    color: var(--primary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#swap-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: rotate(180deg);
}

/* Botões de Ação */
.action-buttons {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid var(--border);
}

#speak-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    color: var(--text-dark);
}

#speak-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Botão Traduzir */
.translate-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.translate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
}

.translate-btn:active {
    transform: translateY(0);
}

.translate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Histórico */
.history-section {
    margin-top: 20px;
}

.history-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--text-dark);
    font-size: 1.2rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    background: #f9fafb;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.history-item .original {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-item .translated {
    color: var(--text-light);
    font-size: 0.95rem;
    padding-left: 28px;
    border-left: 2px solid var(--primary);
    margin-left: 4px;
}

.history-item .lang-indicator {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 4px;
}

.empty-history {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
    font-style: italic;
}

.clear-history-btn {
    margin-top: 16px;
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--error);
    color: var(--error);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    margin-right: auto;
}

.clear-history-btn:hover {
    background: var(--error);
    color: white;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

/* Footer */
footer {
    text-align: center;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}