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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
    background: #f2f2f7;
    min-height: 100vh;
    color: #1c1c1e;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Header */
.header {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1.25rem 2rem;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.logo-link {
    font-size: 1.75rem;
    color: #1c1c1e;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-decoration: none;
    transition: color 0.15s ease;
}

.logo-link:hover {
    color: #007aff;
}

.editor-title {
    color: #8e8e93;
    font-size: 0.875rem;
    font-weight: 400;
}

.controls {
    display: flex;
    gap: 0.5rem;
}

.btn-primary, .btn-secondary {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.875rem;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}

.btn-primary {
    background: #007aff;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 122, 255, 0.3);
}

.btn-primary:hover {
    background: #0056cc;
    transform: translateY(-0.5px);
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 122, 255, 0.3);
}

.btn-secondary {
    background: white;
    color: #1c1c1e;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
}

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

.btn-secondary:active {
    transform: translateY(0);
    background: #e5e5ea;
}

/* Workspace layout */
.workspace {
    display: grid;
    grid-template-columns: 320px 1fr 320px;
    grid-template-rows: 1fr;
    gap: 0;
    padding: 0;
    flex: 1;
    overflow: hidden;
}

/* Main coding area (replaces canvas-container and output-panels) */
.main-coding-area {
    display: flex;
    background: white;
    position: relative;
    overflow: hidden;
}

/* Canvas column - contains canvas and terminal */
.canvas-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Allow flex children to shrink */
}

/* Right panels - contains code and plots */
.right-panels {
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    min-height: 0; /* Allow flex children to shrink */
}

/* Block palette */
.block-palette {
    background: white;
    border-right: 0.5px solid rgba(0, 0, 0, 0.05);
    padding: 1.5rem 1.25rem;
    overflow-y: auto;
    max-height: 100%;
    position: relative;
}

.block-palette h3 {
    color: #1c1c1e;
    margin-bottom: 1.5rem;
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

/* Block sections (expandable main categories) */
.block-section {
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f2f2f7;
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 8px;
    user-select: none;
}

.section-header:hover {
    background: #e5e5ea;
}

.section-toggle {
    font-size: 0.75rem;
    color: #8e8e93;
    transition: transform 0.15s ease;
    font-weight: 500;
}

.section-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1c1c1e;
    letter-spacing: -0.01em;
}

.section-content {
    max-height: 1000px;
    padding: 0.75rem 0 0.75rem 0;
    transition: all 0.25s ease;
    overflow: hidden;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    padding: 0;
    opacity: 0;
}

/* Block subcategories */
.block-subcategory {
    margin-bottom: 1.5rem;
    padding-left: 1rem;
}

.block-subcategory:last-child {
    margin-bottom: 0;
}

.block-subcategory h5 {
    color: #8e8e93;
    font-size: 0.75rem;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
    padding-left: 0.5rem;
}

.block {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    margin-left: 0.5rem;
    background: white;
    color: #1c1c1e;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.15s ease;
    user-select: none;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    font-weight: 400;
    font-size: 0.875rem;
}

.block:hover {
    background: #f2f2f7;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.12);
}

.block:active {
    cursor: grabbing;
    transform: scale(0.98);
    background: #e5e5ea;
}

.block-icon {
    font-size: 1.125rem;
}

/* Canvas container */
.canvas-container {
    background: #f2f2f7;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.canvas {
    flex: 1;
    padding: 2rem;
    min-height: 300px;
    position: relative;
    overflow-y: auto;
    margin-bottom: 1rem;
    background: #fafafa;
    border: 2px dashed #d1d5db;
    border-radius: 16px;
    transition: all 0.2s ease;
}

.drop-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #8e8e93;
    text-align: center;
}

.hint-icon {
    width: 80px;
    height: 80px;
    border: 3px dashed #c7c7cc;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.hint-icon::after {
    content: '+';
    font-size: 2rem;
    color: #c7c7cc;
    font-weight: 300;
}

.drop-hint p {
    font-size: 0.9375rem;
    font-weight: 400;
    opacity: 0.8;
}

.drop-hint.hidden {
    display: none;
}

/* Interactive Terminal Area */
.terminal-area {
    background: white;
    border: 0.5px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    overflow: hidden;
    flex: 0 0 300px; /* Fixed height for terminal */
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
    max-height: 300px; /* Ensure consistent height */
}

.terminal-header {
    background: #f2f2f7;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
    flex-shrink: 0; /* Don't shrink header */
}

.terminal-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #1d1d1f;
}

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

.status-indicator {
    background: #34c759;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-indicator.running {
    background: #ff9500;
}

.status-indicator.error {
    background: #ff3b30;
}

.terminal-content {
    display: flex;
    flex-direction: column;
    flex: 1;
    background: white;
    min-height: 0; /* Allow flex child to shrink */
}

.terminal-output {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    min-height: 0; /* Allow scrolling */
    max-height: 180px; /* Limit height to ensure input is visible */
    scrollbar-width: thin;
    scrollbar-color: #c7c7cc transparent;
}

.terminal-output::-webkit-scrollbar {
    width: 6px;
}

.terminal-output::-webkit-scrollbar-track {
    background: transparent;
}

.terminal-output::-webkit-scrollbar-thumb {
    background-color: #c7c7cc;
    border-radius: 3px;
}

.terminal-output::-webkit-scrollbar-thumb:hover {
    background-color: #a8a8a8;
}

.welcome-message {
    color: #8e8e93;
    margin-bottom: 1rem;
}

.welcome-message p {
    margin: 0.25rem 0;
}

.terminal-input-area {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-top: 0.5px solid rgba(0, 0, 0, 0.05);
    background: #f9f9f9;
    flex-shrink: 0; /* Always keep input visible */
    position: sticky;
    bottom: 0;
}

.prompt {
    color: #007aff;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-weight: 600;
    margin-right: 0.5rem;
    user-select: none;
    flex-shrink: 0;
}

.terminal-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    color: #1d1d1f;
    padding: 0;
    min-width: 0; /* Allow input to shrink */
}

.terminal-input::placeholder {
    color: #8e8e93;
}

.terminal-input:focus {
    outline: none;
    box-shadow: none;
}

/* Terminal output styles */
.terminal-line {
    margin-bottom: 0.25rem;
    word-wrap: break-word;
}

.command-line {
    color: #007aff;
    font-weight: 500;
}

.output-line {
    color: #1d1d1f;
    margin-left: 1.5rem;
}

.error-line {
    color: #ff3b30;
    margin-left: 1.5rem;
}

.success-line {
    color: #34c759;
    margin-left: 1.5rem;
}

/* Canvas blocks */
.canvas-block {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: white;
    color: #1c1c1e;
    border-radius: 16px;
    cursor: move;
    transition: all 0.15s ease;
    user-select: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 0.5px solid rgba(0, 0, 0, 0.04);
    position: relative;
    min-height: 64px;
    font-weight: 500;
}

.canvas-block:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.08);
}

.canvas-block input, .canvas-block select, .canvas-block textarea {
    background: #f2f2f7;
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 6px;
    padding: 0.25rem 0.5rem;
    color: #1c1c1e;
    margin: 0.125rem;
    font-size: 0.8125rem;
    font-family: inherit;
    font-weight: 400;
    -webkit-appearance: none;
    appearance: none;
    min-width: 60px;
    max-width: 120px;
}

.canvas-block input:focus, .canvas-block select:focus, .canvas-block textarea:focus {
    outline: none;
    border-color: #007aff;
    background: white;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.canvas-block .block-name {
    font-weight: 600;
    white-space: nowrap;
    margin-right: 0.5rem;
}

/* Special styling for color and select fields */
.canvas-block select {
    min-width: 80px;
}

/* Field labels for better UX */
.canvas-block input::placeholder,
.canvas-block textarea::placeholder {
    color: #8e8e93;
    font-size: 0.75rem;
}

.canvas-block .field-label {
    font-size: 0.75rem;
    color: #8e8e93;
    font-weight: 500;
    white-space: nowrap;
    margin-right: 0.25rem;
}

/* Basic fields row */
.canvas-block .basic-fields-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.canvas-block .legacy-fields {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Optional fields styling */
.canvas-block .optional-fields {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f2f2f7;
}

.canvas-block .optional-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.canvas-block .option-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: #007aff;
}

.canvas-block .option-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #007aff;
    cursor: pointer;
}

.canvas-block .checkbox-label {
    user-select: none;
    cursor: pointer;
}

.canvas-block .option-input {
    padding-left: 1.5rem;
}

/* Dragging states for canvas blocks */
.canvas-block.dragging {
    opacity: 0.6;
    transform: rotate(2deg);
    z-index: 1000;
}

.canvas-block:not(.dragging) {
    transition: transform 0.15s ease;
}

/* Drop zone indicators */
.canvas.drag-over-block {
    background: rgba(0, 122, 255, 0.03);
}

.canvas-block .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff3b30;
    color: white;
    border: none;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    font-size: 11px;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(255, 59, 48, 0.3);
    font-weight: 600;
}

.canvas-block:hover .remove-btn {
    display: flex;
}

/* Drag states */
.canvas.drag-over {
    background: rgba(0, 122, 255, 0.05);
    border: 2px dashed #007aff;
    border-radius: 16px;
}

.block.dragging {
    opacity: 0.6;
    transform: scale(0.95);
}

/* Output panels */
.output-panels {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: white;
    border-left: 0.5px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.code-panel, .results-panel, .image-panel {
    flex: 1;
    min-height: 200px;
    position: relative;
}

.code-panel {
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
}

.results-panel {
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    position: relative;
    background: #f2f2f7;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.05);
}

.panel-header h3 {
    color: #1d1d1f;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-header h3::before {
    content: "";
    width: 8px;
    height: 8px;
    background: #007aff;
    border-radius: 50%;
    flex-shrink: 0;
}

.image-panel .panel-header h3::before {
    background: #ff9500;
}

.code-panel .panel-header + pre {
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    height: calc(100% - 60px);
}

.image-panel .panel-header + div {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fafafa;
    min-height: 200px;
}

.image-panel .hint {
    color: #8e8e93;
    font-size: 0.9rem;
    text-align: center;
    font-style: italic;
}

#generated-code {
    background: #f8f9fa;
    color: #1d1d1f;
    border: none;
    border-radius: 0;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.6;
    padding: 1.5rem;
    margin: 0;
    overflow: auto;
    height: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
    background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%);
    border-left: 3px solid #007aff;
    position: relative;
    font-weight: 400;
    tab-size: 4;
    resize: none;
}

#generated-code::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(0, 122, 255, 0.3) 50%, transparent 100%);
}

/* Add subtle visual enhancement when code is present */
#generated-code:not(:empty) {
    border-left-color: #34c759;
    background: linear-gradient(145deg, #f8f9fa 0%, #fdfdfd 100%);
}

/* Style code comments in a subtle way */
#generated-code {
    background-image: repeating-linear-gradient(
        transparent,
        transparent 1.5rem,
        rgba(0, 122, 255, 0.02) 1.5rem,
        rgba(0, 122, 255, 0.02) 3rem
    );
}

#output-area {
    background: #f8fafc;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
    font-size: 0.8125rem;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-y: auto;
    height: 100%;
}

#image-area {
    background: #f8fafc;
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#image-area img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
}

/* Resize handles */
.resize-handle {
    position: absolute;
    background: transparent;
    z-index: 100;
    transition: background-color 0.15s ease;
    user-select: none;
}

.resize-handle:hover {
    background: rgba(0, 122, 255, 0.15);
}

.resize-vertical-left {
    left: -2px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
}

.resize-vertical-right {
    right: -2px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
}

.resize-horizontal {
    left: 0;
    right: 0;
    bottom: -2px;
    height: 6px;
    cursor: row-resize;
}

.resize-handle.dragging {
    background: rgba(0, 122, 255, 0.3) !important;
}

/* Visual indicator for resize handles */
.resize-handle:hover::after {
    content: '';
    position: absolute;
    background: #007aff;
}

.resize-vertical-left:hover::after,
.resize-vertical-right:hover::after {
    left: 50%;
    top: 50%;
    width: 2px;
    height: 20px;
    transform: translate(-50%, -50%);
}

.resize-horizontal:hover::after {
    left: 50%;
    top: 50%;
    width: 20px;
    height: 2px;
    transform: translate(-50%, -50%);
}

.hint {
    color: #9ca3af;
    font-style: italic;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.error {
    color: #ef4444;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 0.5rem;
    border-radius: 4px;
    margin-top: 0.5rem;
}

/* Responsive design */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }
    
    .output-panels {
        flex-direction: row;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        text-align: center;
    }
    
    .workspace {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .output-panels {
        flex-direction: column;
    }
}

/* Animation keyframes */
@keyframes slideInFromLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

.canvas-block {
    animation: slideInFromLeft 0.3s ease;
}

.block-palette, .canvas-container, .output-panels > * {
    animation: fadeIn 0.5s ease;
}

/* Driver.js Tour Styling - Beautiful iOS-inspired design */
.driver-popover {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 0.5px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: 20px !important;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.08), 0 12px 32px rgba(0, 0, 0, 0.04) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui !important;
    max-width: 380px !important;
    overflow: hidden !important;
    backdrop-filter: blur(20px) !important;
    animation: driverPopoverEnter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1) !important;
}

.driver-popover-title {
    background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%) !important;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.04) !important;
    border-radius: 20px 20px 0 0 !important;
    padding: 1.5rem 2rem 1.25rem 2rem !important;
    color: #1d1d1f !important;
    font-size: 1.125rem !important;
    font-weight: 600 !important;
    margin: 0 !important;
    position: relative !important;
}

.driver-popover-title::before {
    content: '';
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    width: 5px;
    height: 5px;
    background: #007aff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(0, 122, 255, 0.4);
}

.driver-popover-description {
    padding: 1.25rem 2rem 1.75rem !important;
    color: #424245 !important;
    font-size: 0.9375rem !important;
    line-height: 1.6 !important;
    margin: 0 !important;
    background: white !important;
}

.driver-popover-footer {
    padding: 1.25rem 2rem 1.5rem !important;
    border-top: 0.5px solid rgba(0, 0, 0, 0.04) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: linear-gradient(145deg, #f8f9fa 0%, #ffffff 100%) !important;
}

.driver-popover-btn {
    background: linear-gradient(145deg, #007aff 0%, #0051d5 100%) !important;
    border: none !important;
    border-radius: 14px !important;
    color: white !important;
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    padding: 0.875rem 1.5rem !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
    cursor: pointer !important;
    font-family: inherit !important;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.2) !important;
}

.driver-popover-btn:hover {
    background: linear-gradient(145deg, #0056cc 0%, #003d99 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(0, 122, 255, 0.3) !important;
}

.driver-popover-prev-btn {
    background: linear-gradient(145deg, #f2f2f7 0%, #e5e5ea 100%) !important;
    color: #007aff !important;
    border: 0.5px solid rgba(0, 122, 255, 0.15) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.driver-popover-prev-btn:hover {
    background: linear-gradient(145deg, #e5e5ea 0%, #d1d1d6 100%) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08) !important;
}

.driver-popover-close-btn {
    background: rgba(255, 59, 48, 0.08) !important;
    border: 0.5px solid rgba(255, 59, 48, 0.15) !important;
    color: #ff3b30 !important;
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    border-radius: 50% !important;
    width: 22px !important;
    height: 22px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    top: 1.25rem !important;
    right: 1.25rem !important;
    cursor: pointer !important;
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.driver-popover-close-btn:hover {
    background: rgba(255, 59, 48, 0.12) !important;
    transform: scale(1.1) !important;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.2) !important;
}

.driver-popover-progress-text {
    color: #8e8e93 !important;
    font-size: 0.8125rem !important;
    font-weight: 500 !important;
    background: rgba(142, 142, 147, 0.08) !important;
    padding: 0.375rem 0.875rem !important;
    border-radius: 14px !important;
    border: 0.5px solid rgba(142, 142, 147, 0.15) !important;
    backdrop-filter: blur(10px) !important;
}

.driver-overlay {
    background: rgba(0, 0, 0, 0.2) !important;
    backdrop-filter: blur(2px) !important;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

.driver-highlighted-element {
    background: transparent !important;
    outline: none !important;
    border-radius: 12px !important;
    box-shadow: 
        0 0 0 3px rgba(0, 122, 255, 0.3),
        0 0 0 1px rgba(0, 122, 255, 0.6),
        0 8px 32px rgba(0, 122, 255, 0.12) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* Popover arrow styling */
.driver-popover-arrow {
    border-color: rgba(255, 255, 255, 0.95) !important;
    filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.06)) !important;
}

/* Beautiful entrance animation */
@keyframes driverPopoverEnter {
    0% {
        opacity: 0;
        transform: scale(0.85) translateY(20px);
        filter: blur(4px);
    }
    50% {
        opacity: 0.8;
        filter: blur(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
        filter: blur(0);
    }
}

/* Smooth highlight transition */
.driver-highlighted-element-stage {
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
}

/* File Upload Styling */
.file-input-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.file-upload-btn {
    background: linear-gradient(145deg, #f2f2f7 0%, #ffffff 100%);
    border: 0.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    color: #1d1d1f;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.75rem 1rem;
    transition: all 0.2s ease;
    text-align: center;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.file-upload-btn:hover {
    background: linear-gradient(145deg, #e5e5ea 0%, #f2f2f7 100%);
    border-color: rgba(0, 122, 255, 0.3);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.file-upload-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.file-name {
    font-size: 0.8125rem;
    color: #8e8e93;
    text-align: center;
    padding: 0.25rem 0.5rem;
    border-radius: 8px;
    background: rgba(142, 142, 147, 0.08);
    border: 0.5px solid rgba(142, 142, 147, 0.15);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name:not(:empty) {
    color: #34c759;
    background: rgba(52, 199, 89, 0.08);
    border-color: rgba(52, 199, 89, 0.2);
}

/* File upload animations */
.file-input-container.uploading .file-upload-btn {
    background: linear-gradient(145deg, #007aff 0%, #0051d5 100%);
    color: white;
    pointer-events: none;
}

.file-input-container.uploading .file-name {
    animation: pulse 1.5s ease-in-out infinite;
}

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

/* Drop Zone Styles for Nested Blocks */
.drop-zone {
    margin-top: 0.75rem;
    border: 2px dashed rgba(0, 122, 255, 0.2);
    border-radius: 8px;
    background: rgba(0, 122, 255, 0.02);
    min-height: 60px;
    transition: all 0.2s ease;
    position: relative;
}

.drop-zone-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    height: 60px;
    color: rgba(0, 122, 255, 0.6);
    font-size: 0.8125rem;
    font-weight: 500;
    gap: 0.25rem;
    pointer-events: none;
}

.drop-zone-icon {
    font-size: 1.25rem;
    opacity: 0.7;
}

.drop-zone-text {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Active drop zone highlighting */
.drop-zone-active {
    border-color: #007aff;
    border-style: solid;
    background: rgba(0, 122, 255, 0.08);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
}

.drop-zone-active .drop-zone-placeholder {
    color: #007aff;
}

.drop-zone-active .drop-zone-icon {
    opacity: 1;
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-2px); }
}

/* Nested blocks container */
.nested-blocks-container {
    min-height: 0;
    padding: 0;
}

.nested-blocks-container .canvas-block {
    margin: 0.5rem 0;
    border-left: 3px solid rgba(0, 122, 255, 0.3);
    padding-left: 0.75rem;
    background: rgba(0, 122, 255, 0.02);
    border-radius: 6px;
}

.nested-blocks-container .canvas-block:first-child {
    margin-top: 0.5rem;
}

.nested-blocks-container .canvas-block:last-child {
    margin-bottom: 0.5rem;
}

/* Container blocks styling */
.container-block {
    background: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    border: 1px solid rgba(0, 122, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.08);
}

.container-block .block-name {
    color: #007aff;
    font-weight: 600;
}

/* Hide placeholder when blocks are present */
.drop-zone:has(.nested-blocks-container .canvas-block) .drop-zone-placeholder {
    display: none;
}

/* Drag hover states */
.canvas-block.dragging {
    opacity: 0.5;
    transform: rotate(1deg);
}

/* Drop zone hover during drag */
.drop-zone:hover {
    border-color: rgba(0, 122, 255, 0.4);
    background: rgba(0, 122, 255, 0.04);
}

/* Make drop zones more prominent during drag operations */
body.dragging-palette-block .drop-zone {
    border-color: rgba(0, 122, 255, 0.4);
    background: rgba(0, 122, 255, 0.06);
    animation: dropZonePulse 2s ease-in-out infinite;
}

@keyframes dropZonePulse {
    0%, 100% { 
        box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.1);
    }
    50% { 
        box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
    }
}

/* Responsive adjustments for smaller screens */
@media (max-width: 768px) {
    .drop-zone {
        min-height: 50px;
    }
    
    .drop-zone-placeholder {
        height: 50px;
        font-size: 0.75rem;
    }
    
    .drop-zone-icon {
        font-size: 1rem;
    }
    
    .nested-blocks-container .canvas-block {
        margin: 0.25rem 0;
        padding-left: 0.5rem;
    }
}
