/* ==========================================================================
   Template2 Editor - Grid-based WYSIWYG editor
   ========================================================================== */

.template2-grid {
    display: grid;
    width: 100%;
    height: 100%;
    gap: 0;
}

.template2-cell {
    position: relative;
    background: #ffffff; /* Fixed white - info screen content must not change with app theme */
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px dashed rgba(128, 128, 128, 0.3);
}

/* Empty cell - type selection buttons */
.cell-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.cell-type-buttons {
    display: flex;
    gap: 1rem;
}

.cell-type-btn {
    width: 60px;
    height: 60px;
    border: 2px dashed var(--ip-border-color);
    border-radius: var(--ip-border-radius);
    background: transparent;
    color: var(--ip-text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.cell-type-btn:hover {
    border-color: var(--ip-accent);
    color: var(--ip-accent);
    background: rgba(var(--ip-accent-rgb), 0.1);
}

.cell-type-btn svg {
    width: 24px;
    height: 24px;
}

/* Text cell */
.cell-text {
    width: 100%;
    height: 100%;
    padding: 1rem;
    outline: none;
    overflow: auto;
    font-size: 1rem;
    line-height: 1.5;
}

.cell-text:empty::before {
    content: attr(data-placeholder);
    color: var(--ip-text-tertiary);
    pointer-events: none;
}

.cell-text:focus {
    background: rgba(var(--ip-accent-rgb), 0.05);
}

/* Image cell */
.template2-cell[data-cell-type="image"] {
    background-size: cover;
    background-position: center;
}

.cell-image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.template2-cell[data-cell-type="image"]:hover .cell-image-overlay {
    opacity: 1;
}

.cell-image-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ip-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.cell-image-btn:hover {
    transform: scale(1.1);
}

/* Iframe cell */
.cell-iframe-container {
    width: 100%;
    height: 100%;
}

.cell-iframe-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.cell-iframe-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
}

.cell-iframe-url {
    flex: 1;
    max-width: 300px;
    padding: 0.5rem;
    border: 1px solid var(--ip-border-color);
    border-radius: var(--ip-border-radius);
    background: var(--ip-bg-secondary);
    color: var(--ip-text-primary);
}

/* Reset button (corner X) */
.cell-reset-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.template2-cell:hover .cell-reset-btn {
    opacity: 1;
}

.cell-reset-btn:hover {
    background: var(--ip-danger);
}

.cell-reset-btn svg {
    width: 14px;
    height: 14px;
}

/* TinyMCE styling for template2 cells */
.template2-cell .cell-text {
    width: 100%;
    height: 100%;
    min-height: 60px;
    padding: 8px;
    cursor: text;
}

.template2-cell .cell-text:empty::before {
    content: attr(data-placeholder);
    color: var(--ip-text-muted);
    pointer-events: none;
}

.template2-cell .cell-text:focus {
    outline: none;
}

/* Ensure TinyMCE toolbar appears above other content */
.tox-tinymce-inline {
    z-index: 1100 !important;
}

.tox .tox-toolbar__primary {
    background: var(--ip-bg-elevated) !important;
}

/* Cell menu button (replaces reset button) */
.cell-menu-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 10;
}

.template2-cell:hover .cell-menu-btn {
    opacity: 1;
}

.cell-menu-btn:hover {
    background: rgba(0, 0, 0, 0.7);
}

.cell-menu-btn svg {
    width: 16px;
    height: 16px;
}

/* Cell action menu (dropdown) - uses same patterns as card-menu-dropdown */
.template2-cell-menu {
    position: fixed;
    z-index: 1200;
    background: var(--ip-bg-solid);
    border: 1px solid var(--ip-border-subtle);
    border-radius: var(--ip-radius-xs);
    box-shadow: var(--ip-shadow);
    padding: 4px;
    min-width: 180px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.15s ease;
}

.template2-cell-menu.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.cell-menu-section {
    padding: 4px;
}

.cell-menu-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--ip-text-muted);
    padding: 4px 8px;
    letter-spacing: 0.5px;
}

.cell-menu-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
}

.cell-menu-row input[type="color"] {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 2px solid var(--ip-border-subtle);
    border-radius: 6px;
    cursor: pointer;
    background: var(--ip-bg-solid);
}

.cell-menu-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.cell-menu-row input[type="color"]::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}

.cell-menu-color-label {
    flex: 1;
    font-size: 13px;
    color: var(--ip-text);
}

.cell-menu-clear-bg {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 4px;
    background: var(--ip-bg-subtle);
    color: var(--ip-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.cell-menu-clear-bg:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--ip-danger);
}

.cell-menu-clear-bg svg {
    width: 14px;
    height: 14px;
}

.cell-menu-divider {
    height: 1px;
    background: var(--ip-border-subtle);
    margin: 4px 0;
}

/* Reuse card-menu-item styles for consistency */
.template2-cell-menu .card-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--ip-text);
    font-size: 13px;
    text-align: left;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.template2-cell-menu .card-menu-item:hover {
    background: var(--ip-bg-glass);
}

.template2-cell-menu .card-menu-item svg {
    width: 16px;
    height: 16px;
}

.template2-cell-menu .card-menu-item--danger {
    color: var(--ip-danger);
}

.template2-cell-menu .card-menu-item--danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

