/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --info: #3b82f6;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

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

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    color: white;
    padding: 3rem 1.5rem;
    text-align: center;
}

.logo-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-top: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Sections */
.section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.section h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.section-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Category Grid */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--background);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.category-btn:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.category-btn.active {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.category-icon {
    font-size: 1.5rem;
}

.category-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* Generate Section */
.generate-section {
    text-align: center;
    background: linear-gradient(135deg, var(--primary-light), #ddd6fe);
    border: none;
}

@media (prefers-color-scheme: dark) {
    .generate-section {
        background: linear-gradient(135deg, #312e81, #3730a3);
    }
}

.generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    box-shadow: var(--shadow-lg);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgb(99 102 241 / 0.3);
}

.generate-btn:active {
    transform: translateY(0);
}

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

/* Endpoint Card */
.endpoint-card {
    background: var(--background);
    border-radius: var(--radius-sm);
    padding: 1.5rem;
}

.endpoint-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.method-badge {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 6px;
    text-transform: uppercase;
}

.method-badge.get { background: #dcfce7; color: #166534; }
.method-badge.post { background: #dbeafe; color: #1e40af; }
.method-badge.put { background: #fef3c7; color: #92400e; }
.method-badge.patch { background: #e0e7ff; color: #3730a3; }
.method-badge.delete { background: #fee2e2; color: #991b1b; }

@media (prefers-color-scheme: dark) {
    .method-badge.get { background: #166534; color: #dcfce7; }
    .method-badge.post { background: #1e40af; color: #dbeafe; }
    .method-badge.put { background: #92400e; color: #fef3c7; }
    .method-badge.patch { background: #3730a3; color: #e0e7ff; }
    .method-badge.delete { background: #991b1b; color: #fee2e2; }
}

.endpoint-url {
    flex: 1;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 1rem;
    color: var(--primary-color);
    background: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    word-break: break-all;
}

.copy-btn {
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

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

.endpoint-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* Documentation Links */
.docs-section, .example-section, .params-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.docs-section h3, .example-section h3, .params-section h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.docs-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.docs-links a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.docs-links a:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

/* Code Blocks */
.code-block {
    margin-bottom: 1rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.copy-code-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    background: var(--primary-light);
    color: var(--primary-color);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
}

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

.code-block pre {
    margin: 0;
    padding: 1rem;
    background: #1e293b;
    overflow-x: auto;
}

.code-block code {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.875rem;
    color: #e2e8f0;
    line-height: 1.5;
}

/* Parameters Table */
.params-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.params-table th, .params-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.params-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--surface);
}

.params-table td {
    color: var(--text-primary);
}

.params-table code {
    background: var(--primary-light);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

/* Contribution Form */
.contribution-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    transition: var(--transition);
}

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

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

.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--secondary-color);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.submit-btn:hover {
    background: #059669;
}

/* Contributed Endpoints List */
.contributed-list {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.contributed-list h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.contributed-endpoints {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.contributed-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.contributed-item .method-badge {
    flex-shrink: 0;
}

.contributed-item .endpoint-info {
    flex: 1;
    min-width: 0;
}

.contributed-item .endpoint-path {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--primary-color);
    word-break: break-all;
}

.contributed-item .endpoint-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.contributed-item .use-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.contributed-item .use-btn:hover {
    background: var(--primary-hover);
}

.contributed-item .delete-btn {
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
}

.contributed-item .delete-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* History Section */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.history-item:hover {
    background: var(--primary-light);
}

.history-item .method-badge {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
}

.history-item code {
    flex: 1;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.history-item .timestamp {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.clear-history-btn {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}

.clear-history-btn:hover {
    background: var(--error);
    color: white;
    border-color: var(--error);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--border-color);
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

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

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    background: var(--text-primary);
    color: var(--background);
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

/* Mobile Responsive */
@media (max-width: 640px) {
    .header {
        padding: 2rem 1rem;
    }

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

    .logo-section {
        flex-direction: column;
        gap: 0.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .main-content {
        padding: 1rem;
    }

    .section {
        padding: 1rem;
    }

    .category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .category-btn {
        padding: 0.75rem;
    }

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

    .category-name {
        font-size: 0.75rem;
    }

    .generate-btn {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
        width: 100%;
        justify-content: center;
    }

    .endpoint-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .endpoint-url {
        width: 100%;
        order: 1;
    }

    .copy-btn {
        order: 2;
        align-self: flex-end;
        margin-top: -2.5rem;
    }

    .method-badge {
        order: 0;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .docs-links {
        flex-direction: column;
    }

    .docs-links a {
        width: 100%;
        justify-content: center;
    }

    .params-table {
        font-size: 0.75rem;
    }

    .params-table th, .params-table td {
        padding: 0.5rem;
    }

    .contributed-item {
        flex-wrap: wrap;
    }

    .contributed-item .use-btn,
    .contributed-item .delete-btn {
        margin-top: 0.5rem;
    }

    .history-item {
        flex-wrap: wrap;
    }

    .history-item code {
        width: 100%;
        order: 1;
        margin-top: 0.25rem;
    }

    .history-item .timestamp {
        order: 2;
    }
}

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

.section {
    animation: fadeIn 0.3s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
