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

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --radius: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; width: 100%; }

/* Navbar */
.navbar {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.nav-links { display: flex; gap: 24px; }
.nav-links a {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}
.nav-links a:hover, .nav-links a.active { color: var(--primary); }

/* Main */
main { flex: 1; padding: 40px 20px; }

/* Hero */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero h1 {
    font-size: 2.5rem;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 16px;
}

.hero p { color: var(--text-light); font-size: 1.125rem; }

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
    margin-top: 40px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    border: 1px solid var(--border);
    transition: all 0.3s;
    text-decoration: none;
    color: inherit;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 20px;
}

.card-icon.ocr { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.card-icon.invoice { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.card-icon.bank { background: linear-gradient(135deg, #fef3c7, #fde68a); }

.card h3 { font-size: 1.25rem; margin-bottom: 8px; }
.card p { color: var(--text-light); font-size: 0.9rem; }

/* API Page */
.api-page {
    max-width: 900px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 32px;
}

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

.page-header p { color: var(--text-light); }

/* Form */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.form-card h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group .hint {
    display: block;
    color: var(--text-light);
    font-size: 0.8rem;
    font-weight: 400;
    margin-bottom: 8px;
}

.form-group input[type="text"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea { resize: vertical; min-height: 100px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

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

.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

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

/* Result */
.result-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    display: none;
}

.result-card.show { display: block; }

.result-header {
    padding: 16px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-header h3 { font-size: 1rem; }

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.success { background: #dcfce7; color: #166534; }
.status-badge.error { background: #fef2f2; color: #991b1b; }

.result-body {
    padding: 24px;
}

.result-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    line-height: 1.7;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.02);
}

.upload-area input[type="file"] { display: none; }
.upload-area .icon { font-size: 2rem; margin-bottom: 12px; }
.upload-area p { color: var(--text-light); }
.upload-area .filename { color: var(--primary); font-weight: 600; margin-top: 8px; }

/* Loading */
.loading { display: inline-block; width: 20px; height: 20px; border: 2px solid #fff; border-radius: 50%; border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-light);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .hero h1 { font-size: 1.75rem; }
    .cards-grid { grid-template-columns: 1fr; }
    .form-card { padding: 20px; }
}

/* Upload Preview */
.upload-wrapper {
    position: relative;
}

.upload-wrapper.has-image .upload-area {
    display: none;
}

.preview-container {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

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

.delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 1);
}

.preview-container {
    max-width: 100%;
    overflow: hidden;
}

.preview-container img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

#curlCard pre {
    max-width: 100%;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Card Icons */
.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin-bottom: 20px;
}
.card-icon.ocr { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.card-icon.invoice { background: linear-gradient(135deg, #dcfce7, #bbf7d0); }
.card-icon.bank { background: linear-gradient(135deg, #fef3c7, #fde68a); }

/* Card Badge */
.card-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 16px;
}
.card-badge.live { background: #dcfce7; color: #166534; }
.card-badge.soon { background: #f1f5f9; color: var(--text-light); }

/* Disabled Card */
.card.disabled { opacity: 0.5; pointer-events: none; }

/* API Documentation Page */
.api-page {
    display: flex;
    gap: 40px;
    align-items: flex-start;
}

.sidebar {
    position: sticky;
    top: 80px;
    width: 220px;
    flex-shrink: 0;
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 16px;
    height: fit-content;
}

.sidebar-header {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar a {
    display: block;
    padding: 8px 12px;
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.85rem;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: all 0.2s;
}

.sidebar a:hover {
    background: #f1f5f9;
    color: var(--text);
}

.sidebar a.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
}

.content {
    flex: 1;
    min-width: 0;
}

.section {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    padding: 24px;
    margin-bottom: 24px;
}

.section h2 {
    font-size: 1.25rem;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.section h4 {
    font-size: 1rem;
    margin: 20px 0 12px;
    color: var(--text);
}

.section p {
    color: var(--text-light);
    margin-bottom: 12px;
    line-height: 1.8;
}

.section ul {
    margin: 12px 0;
    padding-left: 24px;
}

.section li {
    color: var(--text-light);
    margin-bottom: 8px;
    line-height: 1.6;
}

/* Tables */
.section table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
}

.section th,
.section td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.section th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--text);
    font-size: 0.85rem;
}

.section td {
    color: var(--text-light);
}

.section code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    color: var(--primary);
}

/* Code Blocks */
.code-block {
    background: #1e293b;
    border-radius: 10px;
    overflow: hidden;
    margin: 16px 0;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.code-header span {
    color: #94a3b8;
    font-size: 0.8rem;
    font-weight: 500;
}

.copy-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #e2e8f0;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: background 0.2s;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.2);
}

.code-block pre {
    padding: 16px;
    margin: 0;
    color: #e2e8f0;
    font-size: 0.85rem;
    line-height: 1.6;
    overflow-x: auto;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
}

/* Method Badge */
.method-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

/* Feature Cards */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 16px 0;
}

.feature-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    text-align: center;
}

.feature-card .icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.feature-card h4 {
    margin-bottom: 8px;
    font-size: 1rem;
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--text-light);
    margin: 4px 0;
}

.feature-card code {
    background: var(--primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Responsive */
@media (max-width: 768px) {
    .api-page {
        flex-direction: column;
    }
    .sidebar {
        position: static;
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px;
    }
    .sidebar-header {
        width: 100%;
        margin-bottom: 8px;
    }
    .sidebar a {
        padding: 6px 12px;
        margin-bottom: 0;
    }
    .feature-cards {
        grid-template-columns: 1fr;
    }
}
