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

body {
    font-family: 'Cal Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Ribbon Interface */
.ribbon-container {
    background: white;
    border-bottom: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ribbon-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.ribbon-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #666;
    transition: all 0.2s ease;
}

.ribbon-tab:hover {
    background: rgba(0,0,0,0.05);
}

.ribbon-tab.active {
    background: white;
    color: #333;
    border-bottom: 2px solid #007acc;
}

.ribbon-tab i {
    font-size: 12px;
}

.ribbon-panels {
    position: relative;
}

.ribbon-panel {
    display: none;
    padding: 12px;
    background: white;
    align-items: flex-start;
    gap: 20px;
}

.ribbon-panel.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.group-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
}

.group-buttons {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    justify-content: center;
}

.ribbon-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 60px;
}

.ribbon-button:hover {
    background: rgba(0,0,0,0.05);
}

.ribbon-button:active {
    background: rgba(0,0,0,0.1);
    transform: translateY(1px);
}

.ribbon-button i {
    font-size: 16px;
    color: #333;
}

.ribbon-button span {
    font-size: 11px;
    color: #666;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.content-mode {
    display: none;
    flex: 1;
    flex-direction: column;
}

.content-mode.active {
    display: flex;
}

/* Build Mode */
.build-mode-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.build-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
    transition: all 0.2s ease;
}

.build-tab:hover {
    background: rgba(0,0,0,0.05);
}

.build-tab.active {
    background: white;
    color: #333;
    border-bottom: 2px solid #007acc;
}

.build-content {
    flex: 1;
    position: relative;
}

.build-view {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

.build-view.active {
    display: block;
}

/* Tree View */
.tree-canvas {
    width: 100%;
    height: 100%;
    overflow: auto;
    background: white;
    position: relative;
    background-image: radial-gradient(circle, #ddd 1px, transparent 1px);
    background-size: 20px 20px;
}

.tree-nodes {
    position: relative;
    min-width: 100%;
    min-height: 100%;
    padding: 40px;
}

.tree-node {
    position: absolute;
    background: white;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 12px;
    min-width: 200px;
    max-width: 250px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.tree-node:hover {
    border-color: #007acc;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tree-node.active {
    border-color: #007acc;
    background: #f0f8ff;
}

.tree-node.executing {
    border-color: #28a745;
    background: #f0fff0;
    animation: pulse 1s infinite;
}

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

.node-header {
    display: flex;
    justify-content: between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.node-id {
    font-family: 'Space Mono', monospace;
    font-size: 12px;
    color: #007acc;
}

.node-content {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.node-content .preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Code View */
#code-editor {
    width: 100%;
    height: 100%;
    border: none;
    padding: 20px;
    font-family: 'Space Mono', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: none;
    outline: none;
    background: #fafafa;
    color: #333;
}

#code-editor:focus {
    background: white;
}

/* Chat Mode */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
}

.chat-header {
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chat-header h3 {
    color: #333;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-status {
    font-size: 12px;
    color: #666;
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 12px;
}

.chat-status.running {
    background: #d4edda;
    color: #155724;
}

.chat-close-button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    margin-left: auto;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.chat-close-button:hover {
    background: rgba(0,0,0,0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 80%;
    animation: fadeIn 0.3s ease;
}

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

.chat-message.bot {
    align-self: flex-start;
}

.chat-message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-message.bot .message-avatar {
    background: #007acc;
    color: white;
}

.chat-message.user .message-avatar {
    background: #6c757d;
    color: white;
}

.message-content {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.user .message-content {
    background: #007acc;
    color: white;
}

.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 12px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

#chat-input:focus {
    border-color: #007acc;
}

#chat-send {
    width: 40px;
    height: 40px;
    border: none;
    background: #007acc;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#chat-send:hover:not(:disabled) {
    background: #0056b3;
    transform: scale(1.05);
}

#chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

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

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

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

.modal-header h3 {
    margin: 0;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.modal-close:hover {
    background: rgba(0,0,0,0.1);
}

.modal-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #007acc;
}

.btn-primary {
    background: #007acc;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-primary:hover {
    background: #0056b3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Block Editor */
.block-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
    background: #fafafa;
}

.line-type {
    font-size: 12px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    min-width: 60px;
    text-align: center;
}

.line-type.message { background: #e3f2fd; color: #1565c0; }
.line-type.ask { background: #f3e5f5; color: #7b1fa2; }
.line-type.if { background: #fff3e0; color: #f57c00; }
.line-type.goto { background: #e8f5e8; color: #388e3c; }
.line-type.wait { background: #fce4ec; color: #c2185b; }
.line-type.set { background: #f1f8e9; color: #689f38; }

.line-content {
    flex: 1;
    font-size: 13px;
    color: #333;
}

.line-actions {
    display: flex;
    gap: 4px;
}

.line-action {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    font-size: 12px;
}

.line-action:hover {
    background: rgba(0,0,0,0.1);
}

/* Project List */
.project-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-item:hover {
    background: #f8f9fa;
    border-color: #007acc;
}

.project-info h4 {
    margin: 0 0 4px 0;
    color: #333;
}

.project-info .project-date {
    font-size: 12px;
    color: #666;
}

.project-actions button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
}

.project-actions button:hover {
    background: #c82333;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .ribbon-panel {
        flex-wrap: wrap;
        gap: 12px;
    }
    
    .ribbon-group {
        min-width: 60px;
    }
    
    .ribbon-button {
        min-width: 50px;
        padding: 6px 8px;
    }
    
    .ribbon-button i {
        font-size: 14px;
    }
    
    .ribbon-button span {
        font-size: 10px;
    }
    
    .tree-node {
        min-width: 150px;
        max-width: 200px;
        font-size: 12px;
    }
    
    .chat-container {
        border: none;
    }
    
    .modal {
        margin: 10px;
        max-height: 90vh;
    }

    .chat-header h3 {
        font-size: 14px;
    }
    
    .chat-status {
        display: none;
    }

    .chat-close-button {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .ribbon-tabs {
        overflow-x: auto;
    }
    
    .build-mode-tabs {
        overflow-x: auto;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .chat-message {
        max-width: 90%;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.text-center {
    text-align: center;
}

.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.ml-2 { margin-left: 8px; }
.mr-2 { margin-right: 8px; }

/* Styles for Command Builder Modal inputs */
.command-input-group label {
    margin-top: 10px; /* Adjust spacing */
}
.command-input-group textarea,
.command-input-group input[type="text"],
.command-input-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box; /* Ensures padding doesn't add to total width */
}
.command-input-group textarea:focus,
.command-input-group input[type="text"]:focus,
.command-input-group input[type="number"]:focus {
    border-color: #007acc;
}