@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg-main: #f4f4f5;
    --bg-sidebar: #ffffff;
    --border-color: #e4e4e7;
    --text-primary: #09090b;
    
    /* Variables dinámicas modificables por el usuario (Valores por defecto) */
    --accent: #2563eb;
    --vitrina-font: 'Inter', sans-serif;
    --vitrina-bg: #ffffff;
    --vitrina-text: #18181b;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: var(--bg-main);
    color: var(--text-primary);
}

/* --- INTERFAZ ESTRUCTURAL --- */
.sidebar {
    width: 360px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h1 {
    font-family: 'Archivo', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
}

.panel-content {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.top-bar {
    height: 60px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
}

.canvas-container {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* --- LIENZO DE LA VITRINA (CANVAS) --- */
.preview-shell {
    width: 100%;
    max-width: 450px;
    background: var(--vitrina-bg) !important;
    color: var(--vitrina-text) !important;
    min-height: 700px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.05);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
    
    /* Centralizamos la fuente dinámica aquí */
    font-family: var(--vitrina-font), sans-serif !important;
}

/* Forzamos el color dinámico y heredamos limpiamente la tipografía del preview shell */
.preview-shell h2, 
.preview-shell h3, 
.preview-shell h4, 
.preview-shell p, 
.preview-shell span {
    font-family: inherit !important;
    color: var(--vitrina-text) !important;
}

.preview-shell button, 
.preview-shell a {
    font-family: inherit !important;
}

/* --- COMPONENTES / BLOQUES DE LA VITRINA --- */
.vitrina-block {
    padding: 24px;
    border-bottom: 1px dashed transparent;
    position: relative;
}

.vitrina-block:hover {
    border-bottom-color: var(--accent);
}

.hero-section {
    text-align: center;
    background: rgba(0, 0, 0, 0.02);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.identity-logo-container {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #e4e4e7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid var(--vitrina-bg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: transform 0.2s;
}

.identity-logo-container:hover, .product-thumb:hover {
    transform: scale(1.03);
    outline: 2px solid var(--accent);
}

.identity-logo-container img, .product-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hero-section h2 {
    font-size: 1.8rem;
    margin-bottom: 4px;
    font-weight: 700;
}

/* Redes Sociales en Vitrina - Pie de Página */
.social-networks-container {
    display: flex;
    gap: 18px;
    margin-top: 16px;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.social-icon-link {
    color: #71717a;
    transition: color 0.2s, transform 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.social-icon-link:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.social-icon-link svg, .btn svg, .product-thumb svg, .sort-handle svg {
    width: 20px !important;
    height: 20px !important;
    display: inline-block;
}

.catalog-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
}

.product-card {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    background: var(--card-bg) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s;
}

.product-thumb {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.04);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a1a1aa;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s;
}

.preview-shell [data-element="product-price"] {
    color: var(--accent) !important;
}

/* --- SECCIÓN DRAG & DROP (SIDEBAR SORTING) --- */
.sortable-list-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.sortable-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f4f4f5;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: grab;
    transition: background 0.15s, opacity 0.15s;
    user-select: none;
}

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

.sortable-item.dragging {
    opacity: 0.4;
    background: #e4e4e7;
    border-style: dashed;
}

.sortable-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.sortable-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sortable-item-price {
    font-size: 0.75rem;
    color: #71717a;
}

.sort-handle {
    color: #a1a1aa;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- INTERFACES DE EDICIÓN --- */
.is-editable {
    cursor: pointer;
    transition: background 0.2s;
    border-radius: 4px;
    padding: 2px 4px;
}

.is-editable:hover {
    background: rgba(37, 99, 235, 0.1);
}

.selected-element {
    outline: 2px solid var(--accent) !important;
    background: rgba(37, 99, 235, 0.05);
}

/* --- ELEMENTOS DE FORMULARIO Y BOTONES --- */
.control-group {
    margin-bottom: 20px;
}

.control-group h3 {
    font-size: 1rem;
    margin-bottom: 10px;
    font-family: 'Archivo', sans-serif;
}

.control-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #71717a;
}

.input-text, .input-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    background: #fff;
}

.input-color {
    width: 100%;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--text-primary);
    color: #fff;
    border: none;
}

.btn-primary:hover { background: #27272a; }
.btn:hover { background: #f4f4f5; }

.accent-bg-btn {
    background-color: var(--accent) !important;
    color: white !important;
    border: none !important;
    cursor: pointer;
}

.product-btn {
    width: 100%;
    padding: 6px;
    font-size: 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #f4f4f5;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s, color 0.2s;
}

.product-btn:hover {
    background: #e4e4e7;
}

/* --- MODAL DE DETALLE AMPLIADO (PROPS ADICIONALES) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(9, 9, 11, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: #ffffff;
    width: 100%;
    max-width: 620px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.25s ease;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-close-btn {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #71717a;
    transition: background 0.2s;
    z-index: 10;
}

.modal-close-btn:hover {
    background: #f4f4f5;
    color: var(--text-primary);
}

.modal-body {
    display: flex;
    flex-direction: row;
}

@media(max-width: 600px) {
    .modal-body { flex-direction: column; }
    .modal-preview-section { height: 180px; }
}

.modal-preview-section {
    flex: 1;
    background: #f4f4f5;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
}

.modal-img-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.modal-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-info-section {
    flex: 1.2;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#modalProductTitle {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: inherit; /* Sincronizado con la tipografía general */
}

.modal-price-tag {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--accent);
}

.modal-description-wrapper {
    margin-top: 4px;
}

.modal-description-wrapper label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #71717a;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.modal-description-wrapper textarea {
    resize: none;
    line-height: 1.4;
}

/* Forzar a que el contenedor de la vitrina y todo lo que esté dentro use la variable */
#previewShell, 
#previewShell * {
    font-family: var(--vitrina-font), sans-serif !important;
}
