/* ==========================================================================
   GG Stones AI Visualizer Layout & Scrolling
   ========================================================================== */

.ggs-hidden {
    display: none !important;
}

.ggs-inline-wrapper {
    display: flex !important;
    flex-direction: row !important;
    gap: 24px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: 1280px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   LEFT STAGE (Canvas & Toolbars)
   -------------------------------------------------------------------------- */
.ggs-main-stage {
    flex: 1 1 68% !important;
    min-width: 0 !important;
    display: flex;
    flex-direction: column;
}

.ggs-stage-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.ggs-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ggs-tool-btn:hover {
    background: #f8fafc;
    border-color: #94a3b8;
}

.ggs-tool-btn.active {
    background: #2563eb !important;
    color: #ffffff !important;
    border-color: #2563eb !important;
}

.ggs-upload-btn {
    background: #0f172a;
    color: #ffffff;
    border-color: #0f172a;
}

.ggs-upload-btn:hover {
    background: #1e293b;
    color: #ffffff;
}

.ggs-status-tag {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0284c7;
    background: #e0f2fe;
    padding: 6px 12px;
    border-radius: 20px;
    margin-left: auto;
}

#ggsCanvasContainer {
    position: relative;
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    background-color: #f8fafc !important;
}

#ggsFabricCanvas {
    width: 100% !important;
    display: block !important;
}

/* Dropzone & AI Loader */
.ggs-dropzone-box {
    border: 2px dashed #d1d5db;
    background-color: #ffffff;
    border-radius: 8px;
    padding: 60px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 420px;
}

.ggs-ai-loader {
    min-height: 420px;
    background: #0f172a;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.ggs-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #334155;
    border-top: 4px solid #38bdf8;
    border-radius: 50%;
    animation: ggsSpin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes ggsSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   RIGHT SIDEBAR & INDEPENDENT STONE CATALOG SCROLLER FIX
   -------------------------------------------------------------------------- */
.ggs-sidebar {
    flex: 0 0 320px !important;
    max-width: 320px !important;
    width: 100% !important;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.04);

    /* Flex structure to fix scroll container */
    display: flex !important;
    flex-direction: column !important;
    max-height: 580px !important; /* Total Sidebar Limit */
    height: auto !important;
    overflow: hidden !important; /* Strictly block sidebar double-scrolling */

    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.ggs-sidebar h3 {
    margin: 0 0 16px 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #111827;
    flex-shrink: 0;
}

/* The actual scrollable grid area */
.ggs-stone-catalog {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    flex: 1 1 auto !important;
    overflow-y: auto !important; /* Dedicated Scrollbar */
    overscroll-behavior: contain;
    padding-right: 6px;
    margin-bottom: 12px;
}

/* Scrollbar Custom Styling */
.ggs-stone-catalog::-webkit-scrollbar {
    width: 6px;
}
.ggs-stone-catalog::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.ggs-stone-catalog::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.ggs-stone-catalog::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Cards Styling */
.ggs-stone-card {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s ease;
    background: #ffffff;
    height: fit-content;
}

.ggs-stone-card * {
    pointer-events: none;
}

.ggs-stone-card:hover {
    border-color: #94a3b8;
}

.ggs-stone-card.active {
    border-color: #111827 !important;
    background: #f9fafb;
    box-shadow: 0 0 0 1px #111827;
}

.ggs-stone-img {
    width: 100%;
    height: 85px;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
}

.ggs-stone-title {
    display: block;
    margin-top: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Footer Section Locked at Bottom */
.ggs-sidebar-footer {
    flex-shrink: 0 !important;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.ggs-download-btn {
    width: 100%;
    background: #16a34a;
    color: #ffffff;
    border: none;
    padding: 12px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.ggs-download-btn:hover:not(:disabled) {
    background: #15803d;
}

.ggs-download-btn:disabled {
    background: #cbd5e1;
    color: #64748b;
    cursor: not-allowed;
}

/* Remove old conflicting classes */
.ggs-stone-grid-container {
    max-height: none !important;
    overflow: visible !important;
}

.ggs-tool-btn.active {
    background-color: #2563eb !important;
    color: #ffffff !important;
    border-color: #2563eb !important;
}

#ggsEraserBtn.active {
    background-color: #dc2626 !important;
    color: #ffffff !important;
    border-color: #dc2626 !important;
}