/* Altegena Invitation Editor - Full Screen Mode */

/* The Modal Container (Hidden by default via inline style) */
body.admin-bar #card-designer.altegena-modal {
    top: 32px !important;
    height: calc(100vh - 32px) !important;
}

@media screen and (max-width: 782px) {
    body.admin-bar #card-designer.altegena-modal {
        top: 46px !important;
        height: calc(100vh - 46px) !important;
    }
}

#card-designer.altegena-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: #ffffff !important;
    z-index: 2147483647 !important;
    /* Max z-index */
    display: flex;
    /* Flex is set by JS, but keep base styles */
    flex-direction: column !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

/* Modal Header */
.altegena-modal-header {
    height: 60px;
    background-color: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    z-index: 10;
    gap: 16px;
}

.altegena-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.altegena-close-btn {
    background: none;
    border: none;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 10px;
}

.altegena-close-btn:hover {
    color: var(--altegena-danger, #d90429);
}

/* Add to Cart Button */
.altegena-add-to-cart-btn {
    background: linear-gradient(135deg, var(--altegena-accent, #d4af37) 0%, var(--altegena-accent-dark, #c5a028) 100%);
    color: #ffffff;
    border: none;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: normal;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    margin-left: auto;
}

.altegena-add-to-cart-btn:hover {
    background: linear-gradient(135deg, var(--altegena-accent-dark, #c5a028) 0%, #b69121 100%);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.4);
    transform: translateY(-1px);
}

.altegena-add-to-cart-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(212, 175, 55, 0.3);
}

/* The active theme (dm-omni) styles this button with letter-spacing via a
   `.altegena-modal #altegena-add-to-cart-btn` !important rule. Override just the
   letter-spacing with two-ID specificity so it wins regardless of load order,
   without disturbing the theme's other button styling. */
#card-designer #altegena-add-to-cart-btn {
    letter-spacing: normal !important;
}

.altegena-add-to-cart-btn.altegena-loading,
.altegena-share-btn.altegena-loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
    padding-left: 40px;
}

.altegena-add-to-cart-btn.altegena-loading::before,
.altegena-share-btn.altegena-loading::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    width: 16px;
    height: 16px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: altegena-spin 0.6s linear infinite;
}

@keyframes altegena-spin {
    to {
        transform: rotate(360deg);
    }
}

/* WhatsApp Share Button (small, floating at the canvas bottom-right so it
   never competes with or blocks the primary "Sepete Ekle" button) */
.altegena-share-btn {
    position: fixed;
    bottom: 16px;
    right: 16px;
    z-index: 30;
    background: var(--altegena-share, #25D366);
    color: #ffffff;
    border: none;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: normal;
    line-height: 1.2;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.altegena-share-btn:hover {
    background: var(--altegena-share-dark, #1ebe5b);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.altegena-share-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Keep the floating button fixed (and spinner anchored) during its loading
   state — the shared .altegena-loading rule sets position:relative, which would
   otherwise snap it back into the header flow. */
.altegena-share-btn.altegena-loading {
    position: fixed;
    padding-left: 34px;
}

/* Share Dialog (overlay inside the full-screen modal) */
.altegena-share-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    box-sizing: border-box;
}

.altegena-share-dialog {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
    text-align: center;
}

.altegena-share-dialog h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.altegena-share-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #999;
}

.altegena-share-close:hover {
    color: var(--altegena-danger, #d90429);
}

.altegena-share-preview {
    max-width: 100%;
    max-height: 45vh;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.altegena-share-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.altegena-share-action {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: filter 0.15s ease, background 0.15s ease;
}

.altegena-share-action.altegena-wa-link,
.altegena-share-action.altegena-wa-image {
    background: var(--altegena-share, #25D366);
    color: #ffffff;
}

.altegena-share-action.altegena-wa-link:hover,
.altegena-share-action.altegena-wa-image:hover {
    background: var(--altegena-share-dark, #1ebe5b);
    color: #ffffff;
}

.altegena-share-action.altegena-copy-link,
.altegena-share-action.altegena-download-img {
    background: #f0f0f0;
    color: #333;
}

.altegena-share-action.altegena-copy-link:hover,
.altegena-share-action.altegena-download-img:hover {
    background: #e4e4e4;
    color: #333;
}

@media (max-width: 900px) {
    .altegena-share-dialog {
        max-width: 94%;
    }

    .altegena-share-preview {
        max-height: 38vh;
    }
}

/* The Editor App Container (Inside Modal) */
#altegena-editor-app {
    flex: 1;
    display: flex;
    overflow: hidden;
    /* Prevent body scroll, handle panels individually */
    background-color: #f5f5f5;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    gap: 0 !important;
    /* Reset gap, use borders */
}

/* Sidebar (Left Panel - Scrollable) */
.altegena-sidebar {
    width: 360px;
    min-width: 360px;
    height: 100%;
    background-color: #ffffff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.02);
    z-index: 5;
}

/* Preview Area (Right Panel) */
.altegena-preview-area {
    flex: 1;
    height: 100%;
    background-color: #eef2f7;
    background-image: radial-gradient(#d1d5db 1px, transparent 1px);
    background-size: 20px 20px;
    display: flex;
    align-items: safe center;
    justify-content: safe center;
    overflow: auto;
    padding: 40px;
}

/* Canvas (sized by JS to maintain exact aspect ratio from JSON config) */
.altegena-canvas {
    position: relative;
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

/* Layers on Canvas */
.altegena-layer {
    position: absolute;
    cursor: move;
    /* Move cursor for draggable */
    white-space: pre;
    overflow: visible;
    outline: none;
    transition: box-shadow 0.2s, transform 0.2s;
    user-select: none;
    /* Prevent text selection while dragging */
}

.altegena-layer:hover {
    box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.5);
    /* Gold outline */
}

.altegena-layer.is-selected,
.altegena-layer:focus {
    box-shadow: 0 0 0 2px var(--altegena-accent, #d4af37);
    z-index: 100;
}

/* Input Groups in Sidebar */
.altegena-input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f0f0;
}

.altegena-input-group:last-child {
    border-bottom: none;
}

.altegena-input-group label {
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    color: #555;
    letter-spacing: 0.5px;
}

.altegena-input-group input[type="text"],
.altegena-input-group textarea,
.altegena-input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fafafa;
}

.altegena-input-group input:focus,
.altegena-input-group textarea:focus,
.altegena-input-group select:focus {
    border-color: var(--altegena-accent, #d4af37);
    background: #fff;
    outline: none;
}

/* Active State Highlighting */
.altegena-input-group.active {
    background-color: #fffbf0;
    border-left: 3px solid var(--altegena-accent, #d4af37);
    padding-left: 10px;
    margin-left: -10px;
    /* Compensate for padding */
    border-radius: 0 4px 4px 0;
}

/* Mobile Responsiveness */
@media (max-width: 900px) {
    #altegena-editor-app {
        flex-direction: column-reverse;
        /* Preview Top, Inputs Bottom */
    }

    .altegena-sidebar {
        width: 100%;
        min-width: 0;
        height: 50%;
        border-right: none;
        border-top: 1px solid #e0e0e0;
    }

    .altegena-preview-area {
        height: 50%;
        padding: 20px;
    }

    .altegena-modal-header {
        height: 50px;
        padding: 0 15px;
    }
}