/* Bento Grid Layout */
.bento-grid-layout {
    display: grid;
    grid-template-columns: 350px 1fr;
    min-height: 600px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

@media (max-width: 992px) {
    .bento-grid-layout {
        grid-template-columns: 1fr;
    }
}

/* Sidebar Controls */
.controls-panel {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 25px;
    overflow-y: auto;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 15px 0;
    border-bottom: 1px solid #edf2f7;
    margin-bottom: 15px;
}

.section-header h2, .section-header h3 {
    font-size: 1.1rem;
    color: #1e293b;
    margin: 0;
    font-weight: 700;
}

.section-header i {
    color: #64748b;
    transition: transform 0.3s;
}

.collapsible-section.collapsed .section-content {
    display: none;
}

.collapsible-section.collapsed .section-header i {
    transform: rotate(-90deg);
}

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

.control-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.value-display {
    font-weight: 600;
    color: #3b82f6;
    background: #eff6ff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Toggle Group for Mobile Cols (NEW) */
.toggle-group {
    display: flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.toggle-group input[type="radio"] {
    display: none;
}

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #64748b;
    transition: all 0.2s;
}

.toggle-group input[type="radio"]:checked + label {
    background: white;
    color: #3b82f6;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}


.btn-tool-action {
    width: 100%;
    padding: 12px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.2s;
}

.btn-tool-action:hover {
    background: #2563eb;
}

.btn-tool-outline {
    width: 100%;
    padding: 12px;
    background: transparent;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-tool-outline:hover {
    background: #f1f5f9;
}

/* Preview Panel */
.preview-panel {
    background: #f1f5f9;
    padding: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
}

/* Viewport Controls */
.viewport-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: white;
    padding: 5px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.btn-viewport {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-viewport:hover {
    background: #f1f5f9;
    color: #64748b;
}

.btn-viewport.active {
    background: #e0f2fe;
    color: #0284c7;
}

/* Workspace */
.bento-workspace {
    display: grid;
    width: 100%;
    max-width: 900px;
    min-height: 400px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    position: relative;
    /* Custom grid pattern for background */
    background-image: radial-gradient(#e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
    
    /* Auto-flow logic */
    grid-auto-flow: dense;
    grid-auto-rows: minmax(100px, auto); 
    align-content: start;
    transition: width 0.3s ease; 
}

/* Mobile View Modification */
.bento-workspace.mobile-view {
    width: 375px;
    max-width: 375px;
    min-height: 600px;
    border: 8px solid #334155;
    border-radius: 30px;
    padding: 15px;
    grid-template-columns: 1fr; 
    gap: 15px !important; 
}

/* Dynamic Mobile Columns */
.bento-workspace.mobile-view[data-mobile-cols="1"] {
    grid-template-columns: 1fr !important;
}
.bento-workspace.mobile-view[data-mobile-cols="2"] {
    grid-template-columns: repeat(2, 1fr) !important;
}

.bento-item {
    background: #3b82f6;
    color: white;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    min-width: 50px;
    min-height: 50px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.2s;
    user-select: none;
    cursor: grab;
    z-index: 1;
}

/* Interactions in Mobile View */
/* Hide resize handle ONLY if we are in 1-column mobile mode (resizing makes no sense there) */
.bento-workspace.mobile-view[data-mobile-cols="1"] .resize-handle {
    display: none;
}
.bento-workspace.mobile-view[data-mobile-cols="1"] .bento-item {
    /* In 1 col mode, drag is ok, but resize is not */
    grid-column: span 1 !important;
}

/* In 2-col mode, allow natural flow + resizing */
.bento-workspace.mobile-view[data-mobile-cols="2"] .resize-handle {
    display: flex; /* Show handles */
}




.bento-item:active {
    cursor: grabbing;
}

.bento-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
    box-shadow: 0 0 0 2px #2563eb;
    z-index: 10;
}

.bento-item.drag-over {
    border: 2px dashed #cbd5e1;
}

.bento-item .item-label {
    font-size: 1.2rem;
    pointer-events: none;
}

.bento-item .item-actions {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s;
}

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

.btn-item-delete {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.7rem;
}

.btn-item-delete:hover {
    background: #ef4444;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
}

.resize-handle::after {
    content: "┘";
    font-size: 20px;
    line-height: 1;
}

/* Code Area */
.code-wrapper {
    margin-top: 40px;
    width: 100%;
    max-width: 900px;
}

.code-header {
    background: #1e293b;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.tabs {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 5px 12px;
    cursor: pointer;
    font-weight: 600;
    border-radius: 4px;
}

.tab-btn.active {
    background: #334155;
    color: #f8fafc;
}

.code-output {
    background: #0f172a;
    padding: 20px;
    border-radius: 0 0 8px 8px;
    margin: 0;
    overflow-x: auto;
}

#code-display {
    color: #38bdf8;
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Info Section */
.tool-info-section {
    padding: 60px 0;
    background: #fff;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.info-card {
    background: #f8fafc;
    padding: 30px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.info-card h4 {
    color: #1e293b;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.info-card p {
    color: #64748b;
    line-height: 1.6;
}
