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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

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

.header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

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

.function-section {
    background: white;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
}

.function-section h2 {
    font-size: 1.4rem;
    margin-bottom: 8px;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.function-section h2::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 2px;
}

.function-section > p {
    color: #666;
    margin-bottom: 24px;
    padding-left: 14px;
}

.direction-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 20px 14px;
}

.direction-control label {
    font-weight: 500;
    color: #2c3e50;
}

.direction-control select {
    padding: 10px 14px;
    font-size: 0.95rem;
    border: 2px solid #d0d5dd;
    border-radius: 8px;
    background: white;
    color: #2c3e50;
}

.direction-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: #2c3e50;
}

.upload-area {
    border: 2px dashed #d0d5dd;
    border-radius: 12px;
    padding: 32px;
    text-align: center;
    transition: all 0.3s ease;
    background: #fafbfc;
}

.upload-area:hover {
    border-color: #667eea;
    background: #f5f7ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #eef1ff;
    border-style: solid;
}

.upload-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
}

.upload-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.upload-btn:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.drop-hint {
    margin-top: 10px;
    color: #94a3b8;
    font-size: 0.85rem;
}

.file-info {
    margin-top: 15px;
    color: #666;
    font-size: 0.9rem;
}

.progress-bar {
    margin-top: 16px;
    background-color: #e8eaed;
    border-radius: 6px;
    overflow: hidden;
    height: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    width: 30%;
    transition: width 0.3s;
    animation: progress-animation 2s ease-in-out infinite;
}

.progress-fill.complete {
    animation: none;
    width: 100%;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

@keyframes progress-animation {
    0% { width: 10%; }
    50% { width: 80%; }
    100% { width: 10%; }
}

.status {
    margin-top: 20px;
    padding: 14px 16px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
}

.status:empty {
    display: none;
}

.status.success {
    background-color: #d1fae5;
    color: #065f46;
    border-left: 4px solid #10b981;
}

.status.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #ef4444;
}

.status.processing {
    background-color: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.download-buttons {
    margin-top: 24px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.download-btn {
    background-color: #e0e0e0;
    color: #999;
    border: none;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: not-allowed;
    transition: all 0.3s ease;
}

.download-btn.ready {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(17, 153, 142, 0.3);
}

.download-btn.ready:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(17, 153, 142, 0.4);
}

/* Summary panel styles */
.summary-panel {
    margin-top: 20px;
    padding: 24px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.summary-panel h3 {
    font-size: 1.1rem;
    color: #2c3e50;
    margin-bottom: 16px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    text-align: center;
    padding: 16px 8px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1.2;
}

.stat-label {
    display: block;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Info notice (e.g., image translation not available) */
.notice.info {
    background-color: #eff6ff;
    border: 1px solid #93c5fd;
    border-left: 4px solid #3b82f6;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    color: #1e40af;
    font-size: 0.9rem;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.notice.info::before {
    content: '\2139';
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    flex-shrink: 0;
}

.unrecognizable-warning {
    background-color: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 16px;
    color: #92400e;
    font-size: 0.9rem;
}

.unrecognizable-warning strong {
    display: block;
    margin-bottom: 8px;
}

.unrecognizable-warning ul {
    margin: 0;
    padding-left: 20px;
}

.unrecognizable-warning li {
    margin-bottom: 4px;
}

/* Action buttons area */
.action-buttons {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.preview-section {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.preview-btn {
    background: #bdc3c7;
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: not-allowed;
    transition: all 0.3s ease;
}

.preview-btn.enabled {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(17, 153, 142, 0.3);
}

.preview-btn.enabled:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(17, 153, 142, 0.4);
}

.preview-hint {
    font-size: 0.85rem;
    color: #92400e;
    font-style: italic;
}

.preview-eta-hint {
    color: #666;
    font-size: 0.9em;
    margin-top: 4px;
    flex-basis: 100%;
    margin-bottom: 0;
}

/* Price quote panel */
.price-quote-panel {
    margin-top: 16px;
    padding: 20px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
}

.price-quote-panel h4 {
    font-size: 1rem;
    color: #0c4a6e;
    margin-bottom: 12px;
}

.price-breakdown {
    margin-bottom: 12px;
}

.price-line {
    font-size: 0.95rem;
    color: #334155;
    padding: 4px 0;
}

.price-total {
    font-size: 1.1rem;
    color: #0c4a6e;
    padding-top: 10px;
    border-top: 1px solid #bae6fd;
    margin-bottom: 16px;
}

.credit-payment-info {
    font-size: 0.9rem;
    color: #334155;
    padding: 10px 14px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    margin-bottom: 16px;
    line-height: 1.5;
}

.credit-payment-info:empty {
    display: none;
}

.price-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.cancel-btn {
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cancel-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* Text translation panels */
.text-translate-panels {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.text-panel {
    position: relative;
}

.text-panel textarea {
    width: 100%;
    min-height: 200px;
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #d0d5dd;
    border-radius: 8px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
    transition: border-color 0.3s ease;
}

.text-panel textarea:focus {
    outline: none;
    border-color: #667eea;
}

.text-panel textarea[readonly] {
    background: #f8fafc;
}

.char-count {
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 6px;
    text-align: right;
}

.char-count.warning {
    color: #ef4444;
    font-weight: 600;
}

.cost-estimate {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
    text-align: right;
    min-height: 1.2em;
}

.cost-estimate:empty {
    display: none;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
    padding: 4px 12px;
    font-size: 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.copy-btn:active {
    background: #cbd5e1;
}

@media (max-width: 768px) {
    .text-translate-panels {
        grid-template-columns: 1fr;
    }
}

/* Login page styles */
.login-section {
    background: white;
    border-radius: 12px;
    padding: 40px;
    max-width: 400px;
    margin: 0 auto;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 1px 3px rgba(0,0,0,0.08);
}

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

.login-form .status {
    margin-top: 0;
    margin-bottom: 10px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #2c3e50;
    font-size: 0.95rem;
}

.form-group input {
    padding: 12px 16px;
    font-size: 1rem;
    border: 2px solid #d0d5dd;
    border-radius: 8px;
    transition: border-color 0.3s ease;
}

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

.login-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(102, 126, 234, 0.3);
    margin-top: 10px;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

/* Logout button in header */
.header-actions {
    margin-top: 15px;
}

.credit-balance {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.9rem;
    margin-right: 12px;
}

.buy-credits-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 4px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-right: 12px;
}

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

.logout-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

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

/* Buy Credits Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    font-size: 1.3rem;
    color: #2c3e50;
    margin-bottom: 8px;
}

.modal-content > p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* Inline buy credits button inside error messages */
.inline-buy-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 4px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 8px;
    vertical-align: middle;
}

.inline-buy-btn:hover {
    opacity: 0.9;
}

/* Task History */
.history-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.history-controls label {
    font-weight: 500;
    color: #2c3e50;
}

.history-controls select {
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 2px solid #d0d5dd;
    border-radius: 8px;
    background: white;
    color: #2c3e50;
}

.refresh-btn {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    border: 1px solid #c7d2fe;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.refresh-btn:hover {
    background: rgba(102, 126, 234, 0.2);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    margin-top: 8px;
}

.history-table thead th {
    text-align: left;
    padding: 10px 12px;
    color: #64748b;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    font-weight: 600;
}

.history-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    vertical-align: middle;
}

.history-table tbody tr:last-child td {
    border-bottom: none;
}

.history-table tbody tr:hover {
    background: #f8fafc;
}

.history-status-pill {
    display: inline-block;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #e2e8f0;
    color: #64748b;
}

.history-status-pill.succeeded {
    background: #d1fae5;
    color: #065f46;
}

.history-status-pill.processing {
    background: #fef3c7;
    color: #92400e;
}

.history-status-pill.failed {
    background: #fee2e2;
    color: #991b1b;
}

.history-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-download-btn {
    display: inline-block;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(17, 153, 142, 0.3);
    transition: all 0.2s ease;
}

.history-download-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(17, 153, 142, 0.4);
}

.history-empty {
    text-align: center;
    color: #94a3b8;
    padding: 32px;
    font-style: italic;
}

@media (max-width: 768px) {
    .history-table {
        font-size: 0.8rem;
    }

    .history-table thead th,
    .history-table tbody td {
        padding: 8px 6px;
    }
}
