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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 1rem 2rem;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

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

.app-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-title i {
    color: #667eea;
    font-size: 1.5rem;
}

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

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

/* Sidebar */
.sidebar {
    width: 350px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    height: fit-content;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

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

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

/* Experiment Metadata Section */
.experiment-metadata {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e2e8f0;
}

.experiment-metadata h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
}

.metadata-form .form-group {
    margin-bottom: 1rem;
}

.metadata-form .form-group:last-child {
    margin-bottom: 0;
}

.metadata-form label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #4a5568;
    margin-bottom: 0.5rem;
}

.metadata-form .form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: all 0.2s ease;
    background: white;
}

.metadata-form .form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.metadata-form textarea.form-control {
    resize: vertical;
    min-height: 60px;
}

.steps-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.step-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.step-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
    transform: translateY(-1px);
}

.step-item.active {
    background: #667eea;
    border-color: #667eea;
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

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

.step-number {
    font-weight: 600;
    font-size: 0.875rem;
    opacity: 0.8;
}

.step-actions {
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.step-item:hover .step-actions {
    opacity: 1;
}

.step-actions button {
    background: none;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.step-actions button:hover {
    background: rgba(0, 0, 0, 0.1);
}

.step-item.active .step-actions button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.step-title {
    font-weight: 500;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.step-description {
    font-size: 0.875rem;
    opacity: 0.8;
    line-height: 1.4;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: #718096;
}

.empty-state i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.empty-state small {
    font-size: 0.875rem;
    opacity: 0.8;
}

/* Editor area */
.editor-area {
    flex: 1;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.editor-content {
    height: 100%;
    min-height: 500px;
}

.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 2rem;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-content i {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 1.5rem;
}

.welcome-content h2 {
    font-size: 2rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 1rem;
}

.welcome-content p {
    font-size: 1.125rem;
    color: #718096;
    margin-bottom: 2rem;
    line-height: 1.6;
}

.step-editor {
    padding: 2rem;
    height: 100%;
    overflow-y: auto;
}

.step-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.step-editor-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #2d3748;
}

.step-form {
    display: grid;
    gap: 1.5rem;
}

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

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

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1rem;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.4);
}

.btn-outline {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

.btn-danger {
    background: #e53e3e;
    color: white;
}

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

/* Form elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: #2d3748;
    font-size: 0.875rem;
}

.form-control {
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    background: white;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control-helper {
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    background: white;
}

.form-control-helper:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-help {
    font-size: 0.75rem;
    color: #718096;
    margin-top: 0.25rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    padding: 2rem;
    align-items: center;
    justify-content: center;
}

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

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

.modal-sm {
    max-width: 400px;
}

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

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2d3748;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    color: #718096;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f7fafc;
    color: #2d3748;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Responsive design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .sidebar {
        width: 100%;
        max-height: 300px;
    }
    
    .chat-container {
        width: 100%;
        min-height: 350px;
        max-height: 400px;
        order: 3; /* Chat appears last on mobile */
    }
    
    .header-content {
        padding: 0 1rem;
    }
    
    .main-content {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .modal {
        margin: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .modal-body {
        padding: 1.5rem;
    }
}

/* Well Plate Selector Styles */
.modal-lg {
    max-width: 90vw;
    width: 1000px;
}

.well-selector-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.plate-type-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.plate-type-selector label {
    font-weight: 600;
    color: #2d3748;
}

.selection-controls {
    display: flex;
    gap: 10px;
}

.instructions {
    background: #e8f4f8;
    border: 1px solid #3498db;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    font-size: 14px;
    color: #2c3e50;
}

.plate-wrapper {
    text-align: center;
    margin: 20px 0;
}

.plate-container {
    position: relative;
    display: inline-block;
    background: #ecf0f1;
    border: 3px solid #34495e;
    border-radius: 10px;
    padding: 20px;
    user-select: none;
}

.plate-grid {
    display: grid;
    gap: 2px;
    position: relative;
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #bdc3c7;
}

.plate-grid.plate-96 {
    grid-template-columns: 30px repeat(12, 25px);
    grid-template-rows: 25px repeat(8, 25px);
}

.plate-grid.plate-384 {
    grid-template-columns: 30px repeat(24, 18px);
    grid-template-rows: 20px repeat(16, 18px);
}

.col-header, .row-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #2c3e50;
    font-size: 12px;
}

.well {
    border-radius: 50%;
    border: 1px solid #95a5a6;
    background: #ecf0f1;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: #7f8c8d;
}

.plate-grid.plate-96 .well {
    width: 22px;
    height: 22px;
}

.plate-grid.plate-384 .well {
    width: 15px;
    height: 15px;
    font-size: 6px;
}

.well:hover {
    border-color: #3498db;
    background: #e8f4f8;
    transform: scale(1.1);
    z-index: 2;
}

.well.selected {
    background: #e74c3c;
    border-color: #c0392b;
    color: white;
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5);
}

.well.highlighted {
    background: #f39c12;
    border-color: #e67e22;
    color: white;
    box-shadow: 0 0 3px rgba(243, 156, 18, 0.5);
}

.selection-box {
    position: absolute;
    border: 2px dashed #3498db;
    background: rgba(52, 152, 219, 0.1);
    pointer-events: none;
    z-index: 10;
}

.selection-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-top: 20px;
}

.selected-wells-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 10px;
    max-height: 100px;
    overflow-y: auto;
}

.well-tag {
    background: #e74c3c;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.well-selector-button {
    background: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    margin-left: 8px;
    transition: background-color 0.2s;
}

.well-selector-button:hover {
    background: #2980b9;
}

@media (max-width: 768px) {
    .modal-lg {
        width: 95vw;
        max-width: none;
    }
    
    .well-selector-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .plate-container {
        padding: 10px;
    }
}

/* Chat Interface Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    width: 400px;
    min-height: 500px;
    max-height: calc(100vh - 140px);
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 12px 12px 0 0;
}

.chat-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-header i {
    color: #667eea;
}

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: #fafafa;
}

.chat-message {
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

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

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
}

.user-message .message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant-message .message-content {
    background: white;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.message-content p {
    margin: 0;
    line-height: 1.5;
}

.chat-input-container {
    padding: 1rem;
    border-top: 1px solid #e2e8f0;
    background: white;
    border-radius: 0 0 12px 12px;
}

.chat-input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 20px;
    max-height: 100px;
}

.chat-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.chat-send-btn {
    padding: 0.75rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

.chat-send-btn:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-1px);
}

.chat-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #718096;
    font-style: italic;
    padding: 0.5rem 1rem;
}

.typing-dots {
    display: flex;
    gap: 2px;
}

.typing-dots span {
    width: 4px;
    height: 4px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

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

@keyframes pulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Responsive chat design */
@media (max-width: 768px) {
    .chat-container {
        min-height: 300px;
        max-height: 350px;
    }
    
    .chat-message {
        max-width: 90%;
    }
    
    .chat-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

.logged-in {
  display: none;  /* hidden by default */
}
.dropdown {
    position: absolute; margin-top: 4px; width: 320px; 
    border: 1px solid #ccc; background: #fff; border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.12); overflow: hidden;
    font-family: system-ui, sans-serif;
  }
.dropdown-item { padding: 8px 10px; cursor: pointer; }
.dropdown-item:hover { background: #f2f2f2; }
.dropdown-item.selected { background: #e9f2ff; }
.cmd-input-wrap { display: flex; align-items: center; gap: 8px; }
.cmd-chip {
  padding: 2px 8px; border-radius: 999px;
  background: #eee; border: 1px solid #ccc; font-family: system-ui, sans-serif;
}

