/* Layout Mods for Full Screen & Ads Sidebar */

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100vh;
    overflow: hidden;
    /* Prevent body scroll, layout handles it */
}

/* Flex Container for Editor + Sidebar */
.main-layout {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Editor Area - Takes remaining space */
.editor-area {
    flex: 1;
    /* Grow to fill space */
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* Fix flex overflow issues */
    position: relative;
}

/* Ads Sidebar */
.ads-sidebar {
    width: 160px !important;
    min-width: 160px !important;
    max-width: 160px !important;
    background-color: #111827;
    border-left: 1px solid #374151;
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.ads-sidebar .ad-content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    padding: 4px;
    overflow-y: auto;
    overflow-x: hidden;
}

.google-ads-container {
    width: 100%;
    overflow: hidden;
}

/* Mobile Ads */
.ads-mobile {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: #0f172a;
    border-top: 1px solid #334155;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.5);
    height: 90px;
}

.ads-placeholder {
    color: #4b5563;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    border: 1px dashed #374151;
    padding: 10px;
    border-radius: 4px;
}

/* Adjustments for internal editor components to fit new container */

/* Top Bar - Color Fixes */
.top-bar {
    position: relative;
    width: 100%;
    z-index: 4000;
    height: auto;
    min-height: 40px;
}

.menu-item {
    color: white !important;
}

.options-bar {
    position: relative;
    top: 0;
    /* Reset top if it was absolute */
    width: 100%;
    height: 40px;
}

.workspace {
    position: relative;
    flex: 1;
    /* Fill remaining vertical space in .editor-area */
    display: flex;
    overflow: hidden;
    height: auto;
    /* Reset fixed height calculations */
}

.status-bar {
    position: relative;
    bottom: 0;
    width: 100%;
    z-index: 50;
}

/* Ensure the Panels (Right Sidebar inside Editor) behave correctly */
.panels {
    /* Rely on flexparent stretch on desktop, and top/bottom bounds on mobile. 
       Removing !important to allow mobile media queries to override height if needed. */
    height: 100%;
}

/* Home Screen Overlay */
#home-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1f2937;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
}

#home-screen h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #60a5fa;
}

#home-screen .actions {
    display: flex;
    gap: 20px;
}

#home-screen .action-btn {
    padding: 15px 30px;
    background: #374151;
    border: 1px solid #4b5563;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
    min-width: 150px;
}

#home-screen .action-btn:hover {
    background: #4b5563;
    transform: translateY(-2px);
}

#home-screen .action-btn i {
    font-size: 2rem;
    margin-bottom: 10px;
    display: block;
    color: #9ca3af;
}

/* Responsive: Hide sidebar on very small screens? Or keep it? 
   User asked for it, so we keep it usually. But maybe stack on mobile? 
   For now, strictly resizing editor. */
@media (max-width: 768px) {
    .ads-sidebar {
        display: none;
        /* Hide ads on mobile to make editor usable */
    }
}

/* Fix Bootstrap Modal Z-Index to be above everything */
.modal-backdrop {
    z-index: 2040 !important;
}

.modal {
    z-index: 2050 !important;
}

/* AI Scanning Effect */
.ai-scan-container {
    position: absolute;
    pointer-events: none;
    z-index: 5000; /* Above everything */
    overflow: hidden;
    border: 2px solid #60a5fa;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
    display: none;
    border-radius: 2px;
    box-sizing: border-box;
    background: rgba(59, 130, 246, 0.05); /* Slight blue tint while scanning */
}

.ai-scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 35%;
    height: 100%;
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(255, 255, 255, 0.1) 10%, 
        rgba(255, 255, 255, 0.9) 50%, 
        rgba(255, 255, 255, 0.1) 90%, 
        transparent 100%
    );
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
    animation: ai-scan-move-gpu 1.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    will-change: transform;
    transform: translateX(-100%);
}

@keyframes ai-scan-move-gpu {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(300%); }
}

/* Premium AI Button Styling */
.ai-bg-btn-premium {
    background: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
    border: none !important;
    color: white !important;
    padding: 0 15px !important;
    border-radius: 20px !important;
    font-weight: 700 !important;
    font-size: 10px !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
    box-shadow: 0 0 8px rgba(168, 85, 247, 0.4);
    height: 22px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.ai-bg-btn-premium:hover {
    transform: translateY(-1px);
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.6);
    filter: brightness(1.1);
}

.ai-bg-btn-premium:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.ai-status-text {
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    margin-left: 8px;
    white-space: nowrap;
}
/* RTL Support */
html[dir="rtl"] .toolbar {
    border-right: none;
    border-left: 1px solid var(--border);
}
html[dir="rtl"] .panels {
    border-left: none;
    border-right: 1px solid var(--border);
}
html[dir="rtl"] #panel-toggler {
    left: auto;
    right: -20px;
    border-radius: 0 8px 8px 0;
    border: 1px solid #4b5563;
    border-left: none;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}
html[dir="rtl"] #panel-toggler i {
    transform: rotate(180deg);
}
html[dir="rtl"] .panels.collapsed #panel-toggler i {
    transform: rotate(0deg);
}
html[dir="rtl"] #history-toggler {
    left: auto;
    right: -20px;
    border-radius: 0 6px 6px 0;
    border-left: none;
    box-shadow: 2px 0 4px rgba(0,0,0,0.2);
}
html[dir="rtl"] #history-float-panel {
    right: auto;
    left: 100%;
    border-radius: 0 8px 8px 0;
    box-shadow: 4px 0 12px rgba(0,0,0,0.3);
}
html[dir="rtl"] .tool-dropdown {
    left: auto;
    right: 100%;
    border-radius: 6px 0 6px 6px;
}
html[dir="rtl"] .menu-items {
    margin-right: auto;
    margin-left: 0;
}
html[dir="rtl"] .ms-auto {
    margin-left: 0 !important;
    margin-right: auto !important;
}
html[dir="rtl"] .dropdown-menu-end {
    right: auto !important;
    left: 0 !important;
}
html[dir="rtl"] .layer-item i {
    margin-right: 0;
    margin-left: 8px;
}
html[dir="rtl"] .layer-name {
    margin-left: 0;
    margin-right: 8px;
}
