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

/* Variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #0f172a;
        --surface: #1e293b;
        --border: #334155;
        --text-primary: #f1f5f9;
        --text-secondary: #94a3b8;
    }
}

/* Base */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--surface);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Container */
.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 32px;
}

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

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Upload Section */
.upload-section {
    background: var(--background);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 32px 20px;
    text-align: center;
    transition: border-color 0.3s;
}

.upload-area:hover {
    border-color: var(--primary-color);
}

.camera-icon {
    width: 64px;
    height: 64px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-placeholder p {
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.upload-methods {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    margin-bottom: 12px;
}

.divider-text {
    color: var(--text-secondary);
    font-size: 13px;
}

.upload-hint {
    font-size: 12px !important;
    margin-bottom: 0 !important;
    opacity: 0.7;
}

.upload-area.paste-active {
    border-color: var(--success-color);
    background: rgba(34, 197, 94, 0.05);
}

.preview-container {
    position: relative;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.preview-container .btn {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* File Info */
.file-info {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-outline {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 18px;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

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

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.action-buttons .btn {
    flex: 1;
}

/* Loading Section */
.loading-section {
    text-align: center;
    padding: 40px 20px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Result Section */
.result-section {
    background: var(--background);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.result-title {
    font-size: 20px;
    margin-bottom: 20px;
}

/* Field Groups */
.field-group {
    margin-bottom: 16px;
}

.field-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-copy-field {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 2px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-copy-field:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.btn-copy-field.copied {
    background: var(--success-color);
    color: white;
    border-color: var(--success-color);
}

.field-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

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

.field-textarea {
    width: 100%;
    min-height: 140px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    line-height: 1.7;
    resize: vertical;
    background: var(--surface);
    color: var(--text-primary);
    transition: border-color 0.2s;
}

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

/* Markdown Preview */
.markdown-preview {
    padding: 20px;
    background: var(--surface);
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.8;
    min-height: 150px;
    word-break: break-word;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3 {
    margin: 16px 0 8px;
    color: var(--text-primary);
}

.markdown-preview h1 { font-size: 18px; }
.markdown-preview h2 { font-size: 16px; }
.markdown-preview h3 { font-size: 15px; }

.markdown-preview p {
    margin: 8px 0;
}

.markdown-preview strong {
    font-weight: 700;
    color: var(--text-primary);
}

.markdown-preview em {
    font-style: italic;
}

.markdown-preview ul,
.markdown-preview ol {
    margin: 8px 0;
    padding-left: 24px;
}

.markdown-preview li {
    margin: 4px 0;
}

.markdown-preview blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
    border-radius: 0 8px 8px 0;
}

.markdown-preview code {
    background: var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.markdown-preview hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

.text-editor {
    position: relative;
}

.text-editor textarea {
    width: 100%;
    min-height: 200px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    line-height: 1.6;
    resize: vertical;
    background: var(--surface);
    color: var(--text-primary);
}

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

.text-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text-primary);
    color: var(--background);
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s;
}

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

/* Mobile Optimization */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }

    .header h1 {
        font-size: 20px;
    }

    .upload-section,
    .result-section {
        padding: 16px;
    }

    .btn-large {
        padding: 14px;
        font-size: 16px;
    }
}

/* Touch Targets */
button,
textarea,
input[type="file"] {
    min-height: 44px;
}
