/* admin-procesador.css - Editor de Alta Fidelidad */

/* Loader homogenization */
#admin-loader {
    position: fixed;
    inset: 0;
    background: linear-gradient(-145deg, #1B396A 0%, #24518F 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    color: white;
    transition: opacity 0.5s ease;
}

.spinner-admin {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinAdmin 0.8s linear infinite;
    margin-bottom: 0;
}

@keyframes spinAdmin {
    to { transform: rotate(360deg); }
}

.loader-text {
    margin-top: 22px;
    color: white;
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    font-weight: 300;
    opacity: 0.85;
}

.admin-layout {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* Editor Main */
.editor-main {
    flex: 1;
    background: #f1f5f9; /* Fondo grisáceo estilo escritorio */
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

/* Toolbar */
.toolbar-container {
    margin: 20px;
    padding: 0;
    border: 1px solid #e2e8f0;
    position: relative;
    z-index: 10;
}

.toolbar-row-top {
    background: #f8fafc;
    padding: 15px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.toolbar-row-bottom {
    padding: 12px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    min-height: 70px;
}

.status-message-area {
    flex: 1;
    font-weight: 600;
    color: #64748b;
    font-size: 14px;
    padding-right: 20px;
}

.button-group-admin {
    display: flex;
    gap: 10px;
}

.nc-input-group { width: 180px; }
.flex-grow-1 { flex: 1; min-width: 200px; }

/* Grid de Editor */
.editor-grid {
    display: flex;
    gap: 0;
    justify-content: center;
    align-items: flex-start; /* Permite que los cuadros definan su altura */
    padding: 0 10px 100px 10px; /* Margen abajo para no perder el borde */
    overflow-y: visible; /* No bloqueamos el scroll aquí */
}

.page-editor-container {
    flex: 0 1 600px;
    min-width: 450px;
    margin: 0 10px;
    display: flex;
    flex-direction: column;
    height: 800px;
}

.page-header-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.page-label-admin { font-weight: 700; color: #1B396A; font-size: 14px; }

.canvas-wrapper-admin {
    flex: 1;
    overflow: auto;
    background: #cbd5e1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px; /* Reducido para maximizar la hoja */
    display: flex;
    min-height: 600px;
}

.canvas-container {
    position: relative;
    margin: auto;
    flex-shrink: 0;
    display: block;
    background: white;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2), 0 0 0 1px rgba(0,0,0,0.1);
    /* Tamaño inicial dinámico para ocupar los extremos */
    width: 98%;
    max-width: 1200px;
    aspect-ratio: 8.5 / 11;
}

/* Cuando ya tiene PDF, el JS tomará el control del ancho y el aspecto será natural */
.has-pdf .canvas-container {
    width: auto;
    aspect-ratio: auto;
}

canvas { display: block; height: auto; }

/* Placeholder Estilo Hoja */
.canvas-placeholder {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    background: white;
    z-index: 5;
    border-radius: 2px;
}

.canvas-placeholder i { font-size: 50px; margin-bottom: 15px; opacity: 0.3; }
.canvas-placeholder span { font-weight: 500; font-size: 14px; opacity: 0.6; }

/* Ocultar placeholder cuando hay PDF */
.has-pdf .canvas-placeholder {
    display: none;
}

/* Máscaras */
.mask-box {
    position: absolute;
    border: 2px solid #ef4444;
    background: rgba(255, 255, 255, 0.95);
    cursor: move;
    box-sizing: border-box;
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.btn-remove-mask {
    position: absolute; top: -12px; right: -12px;
    background: #ef4444; color: white; border: 2px solid white;
    width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    z-index: 100; cursor: pointer; font-size: 16px;
}

/* Resizers invisibles */
.resizer { position: absolute; z-index: 20; background: transparent; }
.resizer.t { top: -5px; left: 0; width: 100%; height: 10px; cursor: n-resize; }
.resizer.b { bottom: -5px; left: 0; width: 100%; height: 10px; cursor: s-resize; }
.resizer.l { left: -5px; top: 0; width: 10px; height: 100%; cursor: w-resize; }
.resizer.r { right: -5px; top: 0; width: 10px; height: 100%; cursor: e-resize; }

/* Botones */
.action-admin-btn {
    height: 40px; padding: 0 18px; font-size: 13px; font-weight: 700;
    border-radius: 8px; cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; gap: 8px; border: none;
}
.btn-white { background: #ffffff; color: #475569; border: 1px solid #d1d5db; }
.btn-white:hover:not(:disabled) { background: #f1f5f9; color: #334155; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(27, 57, 106, 0.08); }
.btn-white:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px rgba(27, 57, 106, 0.05); }

.btn-gray { background: #f1f5f9; color: #1B396A; border: 1px solid #cbd5e1; }
.btn-gray:hover:not(:disabled) { background: #e2e8f0; color: #152d53; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(27, 57, 106, 0.12); }
.btn-gray:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px rgba(27, 57, 106, 0.08); }

.btn-primary-admin { background: #1B396A; color: white; box-shadow: 0 4px 14px rgba(27, 57, 106, 0.18); }
.btn-primary-admin:hover:not(:disabled) { background: #152d53; transform: translateY(-1px); box-shadow: 0 6px 18px rgba(27, 57, 106, 0.28); }
.btn-primary-admin:active:not(:disabled) { transform: translateY(0); box-shadow: 0 2px 8px rgba(27, 57, 106, 0.15); }

.btn-small { padding: 6px 12px; font-size: 12px; height: 32px; }

.action-admin-btn:disabled { background: #e2e8f0 !important; color: #94a3b8 !important; cursor: not-allowed; }

/* Zoom Controls Locales */
.header-actions-admin {
    display: flex;
    align-items: center;
    gap: 15px;
}

.zoom-controls-mini {
    display: flex;
    align-items: center;
    gap: 5px;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.zoom-mini-btn-local {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: white;
    color: #1B396A;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 10px;
}

.zoom-mini-btn-local:hover {
    background: #1B396A;
    color: white;
}

.zoom-val-local {
    font-size: 11px;
    font-weight: 700;
    color: #1B396A;
    min-width: 35px;
    text-align: center;
}

#mobile-editor-notice {
    display: none;
    text-align: center;
    padding: 50px 30px;
    margin: 40px 20px;
    flex-direction: column;
    align-items: center;
    border: 1px solid #e2e8f0;
}

#mobile-editor-notice h2 {
    color: #1B396A;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 15px;
}

#mobile-editor-notice p {
    color: #64748b;
    max-width: 400px;
    line-height: 1.6;
}

#mobile-editor-notice .notice-icon {
    font-size: 60px;
    color: #cbd5e1;
    margin-bottom: 25px;
}

/* RESPONSIVIDAD */
@media (max-width: 991px) {
    .editor-main { overflow-y: auto; height: auto; }
    
    /* Ocultar Editor Real en Móvil */
    .toolbar-container, .editor-grid {
        display: none !important;
    }

    /* Mostrar Aviso */
    #mobile-editor-notice {
        display: flex;
    }
}
