/* Viewport and Box Sizing Stabilization */
*, *::before, *::after {
    box-sizing: border-box !important;
}

html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    position: relative !important;
}

/* Sidebar button text fit fix */
.editor-sidebar {
    gap: 5px !important;
    padding: 8px 6px !important;
}

.editor-tool-button {
    font-size: 10px !important;
    padding: 6px 2px !important;
    min-height: 50px !important;
    flex-shrink: 0 !important;
    text-align: center !important;
}

.ai-tool-icon-vibrant {
    background: linear-gradient(135deg, #fb923c, #ec4899, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 6px rgba(236, 72, 153, 0.8));
    font-size: 18px !important;
    font-weight: 900;
}

.editor-tool-button span {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center !important;
    display: block;
    line-height: 1.2;
}

@media (min-width: 901px) {
    /* Fix side panel height for scrolling on desktop */
    .editor-panel {
        display: flex;
        flex-direction: column;
        max-height: calc(100vh - 100px);
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    overscroll-behavior-x: contain !important;
}

/* Custom Sleek Scrollbar for Header Tools Scroller */
.header-tools-scroller::-webkit-scrollbar {
    height: 3px !important;
}

.header-tools-scroller::-webkit-scrollbar-track {
    background: rgba(30, 39, 56, 0.5) !important;
    border-radius: 99px !important;
}

.header-tools-scroller::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #f43f5e, #f97316) !important;
    border-radius: 99px !important;
}

.header-tools-scroller {
    scrollbar-width: thin !important;
    scrollbar-color: #f97316 rgba(30, 39, 56, 0.5) !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    overscroll-behavior-x: contain !important;
}

.selection-scroller {
    border-right: 1px solid #1e2738;
    padding-right: 6px;
    margin-right: 4px;
}

@media (max-width: 640px) {
    .selection-scroller {
        padding-right: 3px !important;
        margin-right: 2px !important;
    }
}

/* Header Icon Button Active State */
.editor-icon-button.active {
    background: #ec4899 !important;
    color: white !important;
    border-color: #f472b6 !important;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.4) !important;
}

.editor-icon-button {
    white-space: nowrap !important;
}

/* Custom Selection Range Input */
.selection-range-input {
    -webkit-appearance: none;
    width: 100%;
    height: 4px;
    background: #1e293b;
    border-radius: 2px;
    outline: none;
}

.selection-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #ec4899;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.4);
}

.selection-range-input::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #ec4899;
    cursor: pointer;
    border-radius: 50%;
    border: 2px solid #fff;
}

.tool-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.frame-grid-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Gradient Editor Modern Styles */
.gradient-editor-card {
    background: linear-gradient(165deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 12px !important;
}

.gradient-editor-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}

/* Exact Image Design Styles */
.header-tab-btn.active {
    border: 2px solid #ec4899;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.4);
    color: white;
}

#bgGradientSection {
    background: transparent;
}

.gradient-preset-item {
    aspect-ratio: 16/9;
    border-radius: 12px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}
.gradient-preset-item.active, .bg-grid-item.active {
    border-color: #ec4899 !important;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.4) !important;
    transform: scale(0.95);
}
.gradient-preset-item.active::after, .bg-grid-item.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 6px;
    left: 6px;
    background: #ec4899;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 2px solid #0f172a;
}

.gradient-stop-item {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0;
    border-radius: 0;
    background: transparent;
    border: none;
}

.stop-main-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #111827;
    padding: 6px 10px;
    border-radius: 10px;
    border: 1px solid #1f2937;
    flex: 1;
    min-width: 0;
}

.stop-offset-row {
    display: flex;
    align-items: center;
    gap: 4px;
    background: #111827;
    padding: 6px 8px;
    border-radius: 10px;
    border: 1px solid #1f2937;
    margin-left: 6px;
    min-width: 70px;
}

.gradient-stop-circle {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}

.gradient-stop-swatch {
    width: 36px;
    height: 18px;
    border-radius: 4px;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.gradient-stop-swatch input[type="color"] {
    position: absolute;
    inset: -5px;
    width: 50px;
    height: 50px;
    opacity: 0;
    cursor: pointer;
}

.gradient-stop-hex {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gradient-stop-offset-box {
    display: flex;
    align-items: center;
    color: white;
    font-size: 11px;
    font-weight: 600;
}

.gradient-stop-offset-box input {
    background: transparent;
    border: none;
    width: 28px;
    color: white;
    font-size: 11px;
    font-weight: 600;
    text-align: right;
    outline: none;
}

.gradient-stop-delete {
    background: transparent;
    border: none;
    color: #4b5563;
    font-size: 14px;
    cursor: pointer;
    margin-left: 6px;
    transition: color 0.2s;
    flex-shrink: 0;
}
.gradient-stop-delete:hover {
    color: #f87171;
}

/* Background & Frame Category Tabs - Single Horizontal Row (Left-Right Scrollable) */
#bgCategoriesTabsWrapper,
.frame-categories-container {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    scrollbar-width: thin !important;
    padding-bottom: 4px !important;
    margin-bottom: 8px !important;
    background: transparent !important;
}

#bgCategoriesTabs,
.frame-categories-tabs {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 6px !important;
    width: 100% !important;
    max-width: 100% !important;
}

.frame-category-chip {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 6px 12px !important;
    font-size: 11px !important;
    font-weight: 800 !important;
    color: #cbd5e1 !important;
    background: #182131 !important;
    border: 1px solid #334155 !important;
    border-radius: 8px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    cursor: pointer !important;
}

.frame-category-chip.active {
    background: linear-gradient(135deg, #db2777, #f43f5e) !important;
    color: #ffffff !important;
    border-color: #f43f5e !important;
    box-shadow: 0 2px 8px rgba(244, 63, 94, 0.4) !important;
}

/* Background & Frame Images Grid - Single Horizontal Row (62px Small Thumbnails, Left-Right Scrollable) */
.frame-grid-container,
#bgGridWrapper {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    padding-bottom: 4px !important;
}

.frame-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 4px 2px !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: pan-x !important;
    scrollbar-width: thin !important;
    scrollbar-color: #f97316 rgba(30,39,56,0.5) !important;
}

.bg-grid-item,
.frame-item {
    display: inline-block !important;
    width: 62px !important;
    height: 62px !important;
    min-width: 62px !important;
    min-height: 62px !important;
    max-width: 62px !important;
    max-height: 62px !important;
    aspect-ratio: 1 !important;
    border: 2px solid #1e293b !important;
    border-radius: 10px !important;
    overflow: hidden !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: #0f172a !important;
    position: relative !important;
    flex-shrink: 0 !important;
}

.bg-grid-item img,
.frame-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

.bg-grid-item.active,
.frame-item.active {
    border-color: #ec4899 !important;
    box-shadow: 0 0 15px rgba(236, 72, 153, 0.4), inset 0 0 0 2px rgba(236, 72, 153, 0.2) !important;
    transform: scale(0.95) !important;
}

/* Checkmark for active background */
.bg-grid-item.active::after,
.frame-item.active::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 4px;
    left: 4px;
    background: #ec4899;
    color: white;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    font-size: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border: 1.5px solid #0f172a;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Enable page scrolling so user can scroll down to common footer */
html, body.editor-page {
    min-height: 100vh;
    overflow-x: hidden !important;
    overflow-y: auto !important;
}

body.editor-page main {
    height: auto !important;
    min-height: calc(100vh - 100px);
    overflow: visible !important;
}

#commonFooter {
    margin-top: 24px;
    width: 100%;
}

/* AI Tool Button Blinking Effect when launched from Home Page */
@keyframes aiToolBlink {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 rgba(236, 72, 153, 0);
        border-color: rgba(236, 72, 153, 0.2);
    }
    30%, 70% {
        transform: scale(1.08);
        box-shadow: 0 0 25px rgba(236, 72, 153, 0.9), 0 0 12px rgba(168, 85, 247, 0.9);
        border-color: #ec4899;
        background: rgba(236, 72, 153, 0.2) !important;
    }
}

.ai-tool-blink {
    animation: aiToolBlink 0.7s ease-in-out 3 !important;
}
}


