/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: #f8fafc;
    overflow: hidden;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.mermaid-icon {
    font-size: 1.8rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-primary:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
    background: #cbd5e1;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

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

/* Status indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot.connected {
    background-color: #10b981;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.disconnected {
    background-color: #ef4444;
}

.status-dot.connecting {
    background-color: #f59e0b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Main content */
.main {
    display: flex;
    flex: 1;
    min-height: 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 0 1.5rem;
    gap: 1rem;
}

/* Panels */
.editor-panel,
.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-width: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.panel-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
}

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

/* Editor */
.editor-container {
    flex: 1;
    position: relative;
}

#mermaidText {
    width: 100%;
    height: 100%;
    border: none;
    padding: 1.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    background: transparent;
    color: #1e293b;
}

#mermaidText::placeholder {
    color: #94a3b8;
    font-style: italic;
}

/* Preview */
.preview-container {
    flex: 1;
    padding: 1.5rem;
    overflow: auto;
    background: #f8fafc;
}

.mermaid-preview {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-placeholder {
    text-align: center;
    color: #64748b;
}

.placeholder-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.preview-placeholder p {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.preview-placeholder small {
    font-size: 0.875rem;
    opacity: 0.7;
}

/* Mermaid diagram styling */
.mermaid {
    background: white;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid #e2e8f0;
    padding: 1rem 1.5rem;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    font-size: 0.875rem;
    color: #64748b;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.room-label-container {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.room-label {
    font-weight: 500;
}

.info-btn {
    background: none;
    border: none;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.125rem;
    border-radius: 50%;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.info-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.room-select {
    font-family: monospace;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    min-width: 300px;
    cursor: pointer;
}

.room-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

.client-count {
    color: #10b981;
    font-weight: 500;
}

.footer-links {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: #475569;
}

.separator {
    color: #cbd5e1;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid #ef4444;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive design */
@media (max-width: 768px) {
    .main {
        flex-direction: column;
        padding: 0 1rem;
    }

    .editor-panel,
    .preview-panel {
        min-height: 50vh;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }

    .room-info {
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .title {
        font-size: 1.25rem;
    }

    .panel-header {
        padding: 0.75rem 1rem;
    }

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

    .preview-container,
    #mermaidText {
        padding: 1rem;
    }

    .btn {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }

    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* Fullscreen mode */
.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: white;
}

.fullscreen .mermaid-preview {
    height: 100vh;
    padding: 2rem;
}

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

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
