/* ============================================
   styles2.css - Estilos mejorados para widgets y controles
   ============================================ */

/* --- Contenedor de la cuadrícula --- */
.widget-grid {
    width: 100%;
    height: 600px;
    background-color: #fafafa;
    border: 2px dashed #ccc;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    margin-top: 20px;
}

/* --- Widgets base --- */
.grid-widget {
    position: absolute;
    cursor: move;
    user-select: none;
    border: 2px solid transparent;
    transition: border-color 0.2s;
    min-width: 30px;
    min-height: 30px;
    background: rgba(0,0,0,0.02);
    overflow: visible; /* permitir que los controles se extiendan */
}

.grid-widget:hover {
    border-color: var(--primary-color);
}

.grid-widget.selected {
    border-color: var(--primary-color);
}

/* Contenido interno */
.widget-content {
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
}

.widget-content iframe,
.widget-content video {
    width: 100%;
    height: 100%;
    border: none;
}

.widget-content .html-content {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 8px;
    background: white;
    font-size: 14px;
}

.widget-content .text-content {
    width: 100%;
    height: 100%;
    overflow: auto;
    padding: 8px;
    background: white;
    font-size: 14px;
    line-height: 1.6;
}

.widget-content .text-content.ql-editor {
    font-size: inherit;
    line-height: inherit;
    color: inherit;
}

/* --- Panel de controles flotante (reposicionado) --- */
.image-controls {
    /* La posición y coordenadas deben controlar con JS desde positionControls() */
    position: fixed;
    background: rgba(30, 30, 40, 0.95);
    backdrop-filter: blur(8px);
    border-radius: 12px;
    padding: 12px 16px;
    display: none;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.5);
    z-index: 1000;
    min-width: 260px;
    pointer-events: auto;
    border: 1px solid rgba(255,255,255,0.15);
    transition: opacity 0.2s;
}

.image-controls.visible {
    display: flex;
}

.image-controls .controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.image-controls .controls-header .pin-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}
.image-controls .controls-header .pin-btn:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
}
.image-controls .controls-header .pin-btn.pinned {
    color: var(--primary-color);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.control-group label {
    color: #aaa;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
    min-width: 36px;
}

.control-group button {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
}

.control-group button:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.control-group .angle-display {
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    min-width: 34px;
    text-align: center;
}

.pos-input, .size-input {
    width: 40px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #fff;
    padding: 2px 4px;
    font-size: 11px;
    text-align: center;
    height: 24px;
}

.pos-input:focus, .size-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.scale-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    accent-color: var(--primary-color);
}

.scale-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

/* --- Handle de redimensionamiento --- */
.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    cursor: nwse-resize;
    border-radius: 0 0 4px 0;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
}

.grid-widget:hover .resize-handle {
    opacity: 1;
}

/* --- Botones de capa (dentro del panel) --- */
.layer-btn {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    border-radius: 6px;
    padding: 2px 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}
.layer-btn:hover {
    background: var(--primary-color);
}

/* --- Estilos para el modal de HTML con CSS --- */
.modal-content .html-css-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.modal-content .html-css-row label {
    font-weight: 600;
    font-size: 13px;
    color: #555;
}
.modal-content .html-css-row textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: monospace;
    font-size: 13px;
    resize: vertical;
    min-height: 80px;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .widget-grid {
        height: 400px;
    }
    .image-controls {
        width: 100%;
        border-radius: 0;
        padding: 10px;
        flex-wrap: wrap;
        flex-direction: row;
        background: rgba(0,0,0,0.85);
    }
    .control-group {
        flex: 1 1 auto;
        min-width: 80px;
    }
}
.image-controls {
    /* ... estilos existentes ... */
    opacity: 0;
    transition: opacity 0.2s ease, top 0.15s ease, left 0.15s ease;
    pointer-events: none;
}

.image-controls.visible {
    opacity: 1;
    pointer-events: auto;
}