/* Email Translator - Mobile-first Styles */

:root {
    --color-bg: #f5f7fa;
    --color-surface: #ffffff;
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-secondary: #10b981;
    --color-accent: #f59e0b;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-error: #ef4444;
    --color-error-bg: #fef2f2;

    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --transition-speed: 0.2s;
    --border-radius: 12px;
    --border-radius-sm: 8px;
}

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

html {
    font-size: 16px;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    text-align: center;
    padding: 24px 0;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
}

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

/* Main */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    gap: 8px;
    background: var(--color-surface);
    padding: 8px;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mode-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 12px 8px;
    border: none;
    background: transparent;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: inherit;
    color: var(--color-text-muted);
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.mode-btn:hover {
    background: var(--color-bg);
}

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

.mode-icon {
    font-size: 1.25rem;
}

.mode-text {
    font-size: 0.8rem;
    font-weight: 500;
}

/* Input Section */
.input-section {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.input-label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 2px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
    transition: border-color var(--transition-speed);
    line-height: 1.6;
}

.textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.textarea::placeholder {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 8px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-hover);
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
}

.btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
}

.btn-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Result Section */
.result-section {
    background: var(--color-surface);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.3s ease;
}

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

.result-header {
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--color-secondary);
}

.result-text {
    background: var(--color-bg);
    padding: 16px;
    border-radius: var(--border-radius-sm);
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-size: 0.95rem;
}

.result-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.result-actions .btn {
    flex: 1;
}

/* Error Section */
.error-section {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error);
    border-radius: var(--border-radius);
    padding: 16px;
    text-align: center;
}

.error-section p {
    color: var(--color-error);
    margin-bottom: 12px;
    font-weight: 500;
}

.error-section .btn {
    width: auto;
    margin: 0 auto;
}

/* Rate Limit Info */
.rate-limit-info {
    text-align: center;
    padding: 12px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.rate-limit-info.warning {
    color: var(--color-accent);
    font-weight: 500;
}

.rate-limit-info.exhausted {
    color: var(--color-error);
    font-weight: 500;
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

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

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

/* Toast */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-text);
    color: white;
    padding: 12px 24px;
    border-radius: var(--border-radius-sm);
    font-size: 0.9rem;
    z-index: 1000;
    animation: toastIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.toast.success {
    background: var(--color-secondary);
}

.toast.error {
    background: var(--color-error);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Tablet and up */
@media (min-width: 768px) {
    .container {
        padding: 24px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .mode-btn {
        flex-direction: row;
        gap: 8px;
    }

    .mode-text {
        font-size: 0.9rem;
    }

    .textarea {
        min-height: 200px;
    }
}
