/* Text to Diagram - Notion-like UI */

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

:root {
  --font-sans: "Inter", sans-serif;
  --text-color: rgb(25, 25, 24);
  --bg-color: #fafafa;
  --border-color: rgba(55, 53, 47, 0.12);
  --space-16: 16px;
  --space-24: 24px;
  --space-32: 32px;
}

body {
    font-family: var(--font-sans);
    color: var(--text-color);
    background-color: var(--bg-color);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: var(--space-32) var(--space-24);
}

/* ========== APP HEADER ========== */
.app-header {
    text-align: center;
    margin-bottom: var(--space-24);
    padding: var(--space-16) var(--space-24);
    margin: calc(-1 * var(--space-32)) calc(-1 * var(--space-24)) var(--space-24);
}

.app-header__title {
    font-size: 36px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    color: var(--text-color);
    margin: 0;
    padding-bottom: var(--space-16);
}

.app-header__title::after {
    content: "";
    display: block;
    width: 40%;
    height: 1px;
    background: var(--border-color);
    margin: var(--space-16) auto 0;
}

/* Mobile */
@media (max-width: 768px) {
    .container {
        padding: var(--space-24) var(--space-16);
    }

    .app-header {
        padding: 12px var(--space-16);
        margin: calc(-1 * var(--space-24)) calc(-1 * var(--space-16)) var(--space-24);
    }

    .app-header__title {
        font-size: 28px;
    }
}

/* Input Section */
.input-section {
    margin-bottom: 32px;
}

.input-card {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.input-wrapper {
    margin-bottom: 24px;
}

.input-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: rgba(25, 25, 24, 0.6);
    margin-bottom: 8px;
}

textarea {
    width: 100%;
    min-height: 160px;
    padding: 16px;
    font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 18px;
    font-weight: 400;
    line-height: 1.55;
    color: rgb(25, 25, 24);
    background: rgba(55, 53, 47, 0.04);
    border: 0.5px solid rgba(55, 53, 47, 0.16);
    border-radius: 8px;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s ease, background 0.2s ease;
}

textarea:focus {
    border-color: #2383E2;
    background: white;
}

textarea::placeholder {
    color: rgba(25, 25, 24, 0.4);
}

.button-row {
    display: flex;
    justify-content: flex-end;
}

/* Primary Button */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    font-size: 16px;
    font-weight: 500;
    padding: 10px 20px;
    border-radius: 50px;
    background: #000000;
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.btn-primary:hover:not(:disabled) {
    background: #1a1a1a;
}

.btn-primary:active:not(:disabled) {
    background: #333333;
}

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

.btn-primary svg {
    width: 18px;
    height: 18px;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 48px 24px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    margin-top: 24px;
}

.spinner-container {
    margin-bottom: 24px;
}

.spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto;
    border: 3px solid rgba(35, 131, 226, 0.2);
    border-top-color: #2383E2;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 18px;
    font-weight: 500;
    color: rgb(25, 25, 24);
    margin-bottom: 16px;
}

.loading-steps {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}

.loading-steps .step {
    font-size: 14px;
    color: rgba(25, 25, 24, 0.5);
    padding: 6px 12px;
    border-radius: 6px;
    background: rgba(55, 53, 47, 0.04);
    transition: all 0.3s ease;
}

.loading-steps .step.active {
    color: #2383E2;
    background: rgba(35, 131, 226, 0.1);
    font-weight: 500;
}

.loading-steps .step.done {
    color: #16a34a;
    background: rgba(22, 163, 74, 0.1);
}

/* Error State */
.error-state {
    text-align: center;
    padding: 32px 24px;
    background: #fef2f2;
    border: 0.5px solid #fecaca;
    border-radius: 12px;
    margin-top: 24px;
}

.error-icon {
    color: #dc2626;
    margin-bottom: 12px;
}

.error-icon svg {
    width: 40px;
    height: 40px;
}

.error-text {
    font-size: 16px;
    color: #991b1b;
    margin-bottom: 16px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.btn-outline {
    display: inline-flex;
    align-items: center;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 500;
    color: #2383E2;
    background: white;
    border: 0.5px solid #2383E2;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-outline:hover {
    background: rgba(35, 131, 226, 0.08);
}

/* Result Section */
.result-section {
    animation: fadeInUp 0.4s ease;
}

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

.result-card {
    background: white;
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 0.5px solid rgba(55, 53, 47, 0.09);
}

.diagram-title {
    font-size: 28px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: rgb(25, 25, 24);
}

.diagram-badge {
    font-size: 14px;
    font-weight: 500;
    color: #2383E2;
    padding: 6px 12px;
    background: rgba(35, 131, 226, 0.1);
    border-radius: 6px;
    text-transform: capitalize;
}

/* Diagram Container */
.diagram-container {
    position: relative;
    background: #fafafa;
    border: 0.5px solid rgba(55, 53, 47, 0.09);
    border-radius: 8px;
    padding: 16px;
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.diagram-image {
    max-width: 100%;
    max-height: 500px;
    object-fit: contain;
    border-radius: 4px;
}

/* Result Actions */
.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 16px;
    font-weight: 500;
    color: rgba(25, 25, 24, 0.8);
    background: white;
    border: 0.5px solid rgba(55, 53, 47, 0.16);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(55, 53, 47, 0.08);
    border-color: rgba(55, 53, 47, 0.24);
}

.btn-secondary svg {
    width: 18px;
    height: 18px;
}

.btn-secondary.primary {
    background: #2383E2;
    border-color: #2383E2;
    color: white;
}

.btn-secondary.primary:hover {
    background: #1B6DC1;
    border-color: #1B6DC1;
}

/* Footer */
.footer-hint {
    text-align: center;
    margin-top: 48px;
}

.footer-hint p {
    font-size: 14px;
    color: rgba(25, 25, 24, 0.4);
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 24px 16px;
    }
    
    .input-card,
    .result-card {
        padding: 24px;
    }
    
    textarea {
        font-size: 16px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .diagram-title {
        font-size: 24px;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .loading-steps {
        flex-direction: column;
        gap: 8px;
    }
}
