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

:root {
    --primary-color: #4a90d9;
    --primary-hover: #3a7bc8;
    --secondary-color: #6c757d;
    --secondary-hover: #5a6268;
    --background-color: #f5f7fa;
    --surface-color: #ffffff;
    --text-primary: #2c3e50;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.2s ease;
}

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

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* App Container */
.app-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
}

/* Header */
.header {
    text-align: center;
    padding: 20px 0 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    color: var(--primary-color);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-color), #667eea);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 20px;
    min-height: 0;
}

/* Panels */
.editor-panel,
.mindmap-panel {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-color);
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 8px;
}

/* Editor Panel */
.editor-panel {
    min-height: 400px;
}

#markdownInput {
    flex: 1;
    width: 100%;
    padding: 20px;
    border: none;
    resize: none;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--surface-color);
}

#markdownInput:focus {
    outline: none;
}

#markdownInput::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.editor-help {
    padding: 12px 20px;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
}

.editor-help p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Mind Map Panel */
.mindmap-panel {
    min-height: 400px;
}

.mindmap-container {
    flex: 1;
    overflow: hidden;
    position: relative;
    background: linear-gradient(45deg, #fafbfc 25%, transparent 25%),
                linear-gradient(-45deg, #fafbfc 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #fafbfc 75%),
                linear-gradient(-45deg, transparent 75%, #fafbfc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
    cursor: grab;
}

.mindmap-container:active {
    cursor: grabbing;
}

#mindmapSvg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn svg {
    width: 16px;
    height: 16px;
}

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

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

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

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

.btn-icon {
    padding: 8px;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--background-color);
    color: var(--text-primary);
}

/* Customization Panel */
.customization-panel {
    position: fixed;
    right: -320px;
    top: 50%;
    transform: translateY(-50%);
    width: 300px;
    max-height: 80vh;
    background: var(--surface-color);
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.customization-panel.open {
    right: 0;
}

.customization-panel .panel-header {
    padding: 16px 20px;
}

.customization-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

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

.option-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.option-group select,
.option-group input[type="range"] {
    width: 100%;
}

.option-group select {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--surface-color);
    cursor: pointer;
}

.option-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.option-group input[type="range"] {
    -webkit-appearance: none;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    cursor: pointer;
}

.option-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.option-group span {
    display: inline-block;
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Floating Button */
.floating-btn {
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    transition: var(--transition);
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: center;
}

.floating-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.floating-btn svg {
    width: 24px;
    height: 24px;
}

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

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

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

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

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-body {
    padding: 20px;
}

.export-option {
    margin-bottom: 16px;
}

.export-option:last-child {
    margin-bottom: 0;
}

.export-option label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.export-option select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--surface-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    background: var(--background-color);
    border-top: 1px solid var(--border-color);
}

/* Mind Map Nodes */
.node {
    cursor: pointer;
    transition: var(--transition);
}

.node:hover .node-bg {
    filter: brightness(0.95);
}

.node-bg {
    transition: var(--transition);
}

.node-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    pointer-events: none;
}

.connection {
    fill: none;
    stroke-width: 2;
    opacity: 0.6;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    padding: 40px;
    text-align: center;
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .editor-panel {
        min-height: 250px;
    }

    .mindmap-panel {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 12px;
    }

    .header {
        padding: 15px 0 20px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    .tagline {
        font-size: 0.85rem;
    }

    .panel-header {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .panel-actions {
        flex-wrap: wrap;
    }

    .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .btn svg {
        width: 14px;
        height: 14px;
    }

    #markdownInput {
        padding: 15px;
        font-size: 13px;
    }

    .customization-panel {
        width: 100%;
        right: -100%;
        max-height: 70vh;
        bottom: 0;
        top: auto;
        transform: none;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .customization-panel.open {
        right: 0;
    }

    .floating-btn {
        width: 44px;
        height: 44px;
        right: 15px;
        bottom: 70px;
    }

    .floating-btn svg {
        width: 20px;
        height: 20px;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }
}

@media (max-width: 480px) {
    .logo h1 {
        font-size: 1.2rem;
    }

    .panel-header h2 {
        font-size: 0.9rem;
    }

    .editor-panel {
        min-height: 200px;
    }

    .mindmap-panel {
        min-height: 300px;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.node {
    animation: fadeIn 0.3s ease;
}

/* Tooltip */
.tooltip {
    position: absolute;
    background: var(--text-primary);
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 1000;
    white-space: nowrap;
}

/* Node selection */
.node.selected .node-bg {
    stroke: var(--primary-color);
    stroke-width: 3;
}

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

::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: 4px;
}

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

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