/* ===== CSS Variables ===== */
:root {
    --bg-primary: #f8fafc;
    --bg-card: #ffffff;
    --bg-code: #1e293b;
    --bg-input: #f1f5f9;
    
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #dbeafe;
    
    --success: #22c55e;
    --success-light: #dcfce7;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* ===== Container ===== */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 40px 20px 60px;
}

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

.title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--bg-card);
    padding: 6px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab:hover {
    color: var(--text-primary);
    background: var(--bg-input);
}

.tab.active {
    background: var(--accent);
    color: white;
}

.tab svg {
    flex-shrink: 0;
}

/* ===== Tab Content ===== */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

/* ===== Section Card ===== */
.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: var(--accent-light);
    border-radius: var(--radius-md);
    color: var(--accent);
    flex-shrink: 0;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

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

.section-subtitle code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* ===== Card Title ===== */
.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

.card-subtitle code {
    font-family: var(--font-mono);
    font-size: 13px;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* ===== Steps ===== */
.step {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-light);
}

.step:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.step:first-of-type {
    padding-top: 0;
}

.step-header {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.step-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 50%;
    flex-shrink: 0;
}

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

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

/* ===== Code Block ===== */
.code-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-code);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 12px;
    gap: 12px;
}

.code-block code {
    font-family: var(--font-mono);
    font-size: 14px;
    color: #e2e8f0;
    white-space: nowrap;
    overflow-x: auto;
}

/* ===== Code Block Large ===== */
.code-block-large {
    background: var(--bg-code);
    border-radius: var(--radius-md);
    overflow: hidden;
}

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

.code-filename {
    font-family: var(--font-mono);
    font-size: 13px;
    color: #94a3b8;
}

.code-block-large pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-block-large code {
    font-family: var(--font-mono);
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.6;
    white-space: pre;
    display: block;
}

/* ===== Copy Button ===== */
.copy-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    color: white;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: var(--accent-hover);
}

.copy-btn.copied {
    background: var(--success);
}

.copy-btn .check-icon {
    display: none;
}

.copy-btn.copied .copy-icon {
    display: none;
}

.copy-btn.copied .check-icon {
    display: block;
}

/* ===== Info & Warning Boxes ===== */
.info-box,
.warning-box {
    display: flex;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-top: 12px;
    line-height: 1.5;
}

.info-box {
    background: var(--accent-light);
    color: var(--accent);
}

.info-box code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(37, 99, 235, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
}

.warning-box {
    background: var(--warning-light);
    color: #92400e;
}

.warning-box code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: rgba(146, 64, 14, 0.15);
    padding: 1px 4px;
    border-radius: 3px;
}

.info-box svg,
.warning-box svg {
    flex-shrink: 0;
    margin-top: 1px;
}

/* ===== Stack Grid ===== */
.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.stack-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: var(--bg-input);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.stack-card:hover {
    border-color: var(--accent);
    background: white;
}

.stack-card.active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.stack-emoji {
    font-size: 28px;
}

.stack-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.stack-hint {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
}

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

/* ===== Selected Stack Banner ===== */
.selected-stack-banner {
    padding: 14px 18px;
    background: var(--success-light);
    border-left: 4px solid var(--success);
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-size: 14px;
    color: #166534;
}

.selected-stack-banner strong {
    font-weight: 600;
}

/* ===== Config Block ===== */
.config-block {
    margin-bottom: 28px;
}

.config-block:last-child {
    margin-bottom: 0;
}

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

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

/* ===== Port Buttons ===== */
.port-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.port-btn {
    padding: 10px 20px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.port-btn:hover {
    border-color: var(--accent);
}

.port-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.port-btn .rec {
    font-size: 11px;
    opacity: 0.8;
}

/* ===== Text Input ===== */
.text-input {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--accent);
}

.text-input::placeholder {
    color: var(--text-muted);
}

/* ===== Textarea Input ===== */
.input-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.textarea-input {
    width: 100%;
    min-height: 180px;
    padding: 14px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-primary);
    resize: vertical;
    transition: border-color 0.2s ease;
    line-height: 1.6;
}

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

.textarea-input::placeholder {
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ===== Generate Button ===== */
.generate-btn {
    display: block;
    width: 100%;
    padding: 14px 24px;
    margin-top: 16px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 15px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: background 0.2s ease;
}

.generate-btn:hover {
    background: var(--accent-hover);
}

/* ===== Generated Code Wrapper ===== */
.generated-code-wrapper {
    margin-top: 20px;
}

/* ===== Warning Header ===== */
.warning-header {
    display: flex;
    gap: 12px;
    padding: 16px;
    background: var(--warning-light);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.warning-header svg {
    flex-shrink: 0;
    color: var(--warning);
    margin-top: 2px;
}

.warning-header .block-title {
    margin-bottom: 4px;
}

.warning-header .block-subtitle {
    margin-bottom: 0;
    font-size: 13px;
}

/* ===== Contact Form ===== */
.contact-section {
    margin-top: 32px;
}

.contact-icon {
    background: #fef3c7;
    color: #d97706;
}

.contact-form {
    margin-top: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

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

.submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
}

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

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

.submit-btn .btn-loading,
.submit-btn .btn-success {
    display: none;
}

.submit-btn.loading .btn-text {
    display: none;
}

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

.submit-btn.success {
    background: var(--success);
}

.submit-btn.success .btn-text,
.submit-btn.success .btn-loading {
    display: none;
}

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

.spinner {
    animation: spin 1s linear infinite;
}

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

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-code);
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

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

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

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container {
        padding: 24px 16px 40px;
    }
    
    .title {
        font-size: 24px;
    }
    
    .tabs {
        flex-direction: column;
    }
    
    .tab {
        justify-content: flex-start;
    }
    
    .section-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .section-icon {
        width: 40px;
        height: 40px;
    }
    
    .stack-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .code-block {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .code-block .copy-btn {
        align-self: flex-end;
    }
    
    .code-block code {
        font-size: 13px;
    }
    
    .port-buttons {
        flex-direction: column;
    }
    
    .port-btn {
        text-align: center;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 22px;
    }
    
    .section-card {
        padding: 16px;
    }
    
    .step-header {
        flex-direction: column;
        gap: 12px;
    }
    
    .stack-grid {
        grid-template-columns: 1fr;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

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