@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
    --bg-1: #07111f;
    --bg-2: #0e1c2d;
    --bg-3: rgba(11, 23, 39, 0.78);
    --bg-4: rgba(15, 28, 47, 0.92);
    --panel-top: rgba(255, 255, 255, 0.03);
    --line: rgba(120, 173, 220, 0.16);
    --line-strong: rgba(132, 193, 255, 0.28);
    --text-main: #ecf4ff;
    --text-soft: #acc0d5;
    --text-dim: #6f859c;
    --accent: #63d2ff;
    --accent-2: #8ef6c7;
    --accent-3: #ffbc6d;
    --danger-bg: rgba(255, 115, 115, 0.12);
    --danger-line: rgba(255, 115, 115, 0.35);
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    font-family: 'Manrope', sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(circle at top left, rgba(99, 210, 255, 0.16), transparent 30%),
        radial-gradient(circle at 85% 10%, rgba(142, 246, 199, 0.14), transparent 25%),
        linear-gradient(135deg, #05101c 0%, #0b1626 55%, #0f2034 100%);
}

.parallax-bg {
    position: fixed;
    inset: -10%;
    z-index: -1;
    background:
        radial-gradient(circle at 20% 25%, rgba(99, 210, 255, 0.08), transparent 24%),
        radial-gradient(circle at 80% 75%, rgba(255, 188, 109, 0.06), transparent 18%),
        linear-gradient(135deg, rgba(255, 255, 255, 0.02), transparent);
    filter: blur(10px);
    animation: gradientShift 18s ease-in-out infinite;
}

@keyframes gradientShift {
    0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
    50% { transform: translate3d(10px, 12px, 0) scale(1.03); }
}

header {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 17, 31, 0.72);
    backdrop-filter: blur(18px);
}

.header-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #04111d;
    font-size: 1.35rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 10px 30px rgba(99, 210, 255, 0.28);
}

.server-name {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: 0.01em;
}

.header-subtitle {
    margin-top: 0.15rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.info-btn,
.panel-btn,
.chip-btn {
    border: 1px solid var(--line);
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.info-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 1rem;
}

.info-btn:hover,
.panel-btn:hover,
.chip-btn:hover {
    transform: translateY(-2px);
    border-color: var(--line-strong);
    background: rgba(99, 210, 255, 0.08);
}

.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

.hero-card {
    display: none;
}

.workspace {
    display: grid;
    grid-template-columns: minmax(480px, 1.1fr) minmax(420px, 0.9fr);
    gap: 1.5rem;
    min-height: calc(100vh - 280px);
}

.editor-panel,
.preview-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 28px;
    overflow: hidden;
    background:
        linear-gradient(180deg, var(--panel-top), transparent 30%),
        var(--bg-3);
    box-shadow: var(--shadow);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.35rem 1.4rem 1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.02);
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--accent);
}

.panel-subtitle {
    margin-top: 0.35rem;
    color: var(--text-dim);
    font-size: 0.88rem;
}

.panel-actions {
    display: flex;
    gap: 0.65rem;
}

.panel-btn {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.editor-toolbar {
    padding: 0.9rem 1.25rem 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.chip-btn {
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    font-family: 'Manrope', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
}

.editor-shell {
    height: 550px;
    margin: 1rem 1.25rem 0;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 22px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-4);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.editor-topline {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.95rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
}

.editor-dot {
    width: 11px;
    height: 11px;
    border-radius: 50%;
}

.editor-dot.red { background: #ff6b6b; }
.editor-dot.amber { background: #ffc76b; }
.editor-dot.green { background: #65dc98; }

.editor-filename {
    margin-left: 0.4rem;
    color: var(--text-soft);
    font-size: 0.92rem;
    font-weight: 700;
}

.editor-container {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 64px, transparent 64px);
}

.editor-gutter {
    overflow: hidden;
    padding: 1.2rem 0 1.2rem 1rem;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.65;
    color: #567089;
    user-select: none;
}

.editor-gutter span {
    display: block;
    text-align: right;
    padding-right: 0.8rem;
}

.editor-container textarea {
    width: 100%;
    height: 100%;
    padding: 1.2rem 1.2rem 1.2rem 1rem;
    border: none;
    outline: none;
    resize: none;
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    color: var(--text-main);
    caret-color: var(--accent-2);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    line-height: 1.65;
    tab-size: 4;
}

.editor-container textarea::selection {
    background: rgba(99, 210, 255, 0.2);
}

.editor-container textarea::placeholder {
    color: #597088;
}

.editor-statusbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-dim);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
}

.editor-footer {
    padding: 1.15rem 1.25rem 1.25rem;
}

.generate-btn {
    width: 100%;
    padding: 1rem 1.25rem;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    color: #04111d;
    font-family: 'Manrope', sans-serif;
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    box-shadow: 0 16px 32px rgba(99, 210, 255, 0.22);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 22px 40px rgba(99, 210, 255, 0.28);
}

.preview-container {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background:
        radial-gradient(circle at center, rgba(99, 210, 255, 0.06), transparent 60%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent);
}

.flowchart-img {
    display: none;
    max-width: 100%;
    max-height: 100%;
    object-fit: scale-down;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
}

.empty-state,
.spinner,
.error-state {
    max-width: 540px;
    padding: 1.4rem;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    border-radius: 22px;
    text-align: center;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.025);
}

.empty-state i {
    font-size: 2.7rem;
    color: var(--accent);
}

.spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.025);
}

.spinner-ring {
    width: 54px;
    height: 54px;
    border: 3px solid rgba(99, 210, 255, 0.18);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.error-state {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--danger-bg);
    border-color: var(--danger-line);
    color: #ffc2c2;
    line-height: 1.6;
    white-space: pre-wrap;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.62);
    backdrop-filter: blur(8px);
}

.modal-content {
    position: relative;
    width: min(95%, 1100px);
    max-height: 86vh;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: rgba(10, 20, 34, 0.96);
    box-shadow: var(--shadow);
    animation: slideIn 0.25s ease;
}

.modal-content.small {
    max-width: 480px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.4rem 1.6rem;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--accent);
    font-size: 1.1rem;
}

.modal-close {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
    cursor: pointer;
}

.modal-body {
    padding: 1.6rem;
}

.info-section + .info-section {
    margin-top: 1.4rem;
}

.info-section h3 {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.65rem;
    color: var(--accent-2);
    font-size: 1rem;
}

.info-section p {
    color: var(--text-soft);
    line-height: 1.65;
}

.code-example {
    margin-top: 0.75rem;
    padding: 0.95rem 1rem;
    border: 1px solid rgba(99, 210, 255, 0.14);
    border-radius: 14px;
    background: rgba(99, 210, 255, 0.06);
    color: #d8f2ff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    line-height: 1.65;
    overflow-x: auto;
}

@media (max-width: 1200px) {
    .hero-card,
    .workspace {
        grid-template-columns: 1fr;
    }

    .workspace {
        min-height: auto;
    }

    .editor-panel,
    .preview-panel {
        min-height: 540px;
    }
}

@media (max-width: 768px) {
    .header-content,
    .main-container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .hero-card {
        padding: 1.25rem;
    }

    .hero-card h1 {
        max-width: none;
        font-size: 2rem;
    }

    .panel-header {
        flex-direction: column;
    }

    .editor-container {
        grid-template-columns: 52px minmax(0, 1fr);
    }

    .editor-gutter {
        padding-left: 0.55rem;
    }

    .editor-statusbar {
        flex-direction: column;
    }
}

.modal-buttons {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.modal-btn {
    padding: 0.65rem 1.2rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    font-family: 'Manrope', sans-serif;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn.cancel {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.modal-btn.cancel:hover {
    border-color: var(--line-strong);
    background: rgba(99, 210, 255, 0.08);
    transform: translateY(-2px);
}

.modal-btn.confirm {
    color: #04111d;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    border: none;
    box-shadow: 0 8px 16px rgba(99, 210, 255, 0.22);
}

.modal-btn.confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(99, 210, 255, 0.28);
}

.notification {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.4rem;
    background: linear-gradient(135deg, #1a4d6d, #0f3a52);
    border: 1px solid rgba(99, 210, 255, 0.35);
    border-radius: 12px;
    color: var(--text-main);
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2001;
    opacity: 0;
    animation: slideInRight 0.3s ease;
    pointer-events: none;
}

.notification.show {
    opacity: 1;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
