/* ai_kids_print_style.css */

:root { 
    --primary: #FF6B6B; 
    --secondary: #4ECDC4; 
    --accent: #2ecc71; 
    --dark: #2C3E50; 
    --paper: #ffffff; 
    --bg: #f0f9ff;
}

* { box-sizing: border-box; }

body { 
    font-family: 'Comic Sans MS', 'Chalkboard SE', sans-serif; 
    background-color: var(--bg); 
    margin: 0; 
    padding: 20px; 
    text-align: center; 
    color: var(--dark);
}

/* --- MAIN CARD --- */
.card { 
    background: var(--paper); 
    width: 100%;
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 30px; 
    border-radius: 30px; 
    box-shadow: 0 20px 60px rgba(0,0,0,0.1); 
    border: 4px solid var(--dark); 
    display: flex; 
    flex-direction: column;
    gap: 30px;
}

h1 { color: var(--dark); margin: 0; font-size: 2.5rem; }
p.subtitle { font-size: 1.2rem; color: #666; margin: 10px 0 20px; }

/* --- RESPONSIVE LAYOUT ENGINE --- */
.app-body { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 30px; 
    align-items: flex-start;
}

.main-section { 
    flex: 2 1 600px; 
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- SIDEBAR (ARCHIVE) FIX --- */
.sidebar {
    flex: 1 1 350px; 
    background: #f8f9fa;
    border: 3px dashed #cbd5e0;
    border-radius: 20px;
    padding: 20px;
    
    /* FIX: Force scrollbar track to stay visible to prevent jumping */
    max-height: 85vh; 
    overflow-y: scroll; /* Always show vertical scrollbar track */
    scrollbar-gutter: stable; /* Modern browser fix */
    
    scrollbar-width: thin;
    scrollbar-color: var(--secondary) #eee;
}

/* --- INPUTS & BUTTONS --- */
.input-group { display: flex; gap: 10px; flex-wrap: wrap; }

input { 
    flex: 1 1 200px; 
    padding: 18px; 
    font-size: 1.2rem; 
    border: 3px solid #cbd5e0; 
    border-radius: 15px; 
    outline: none; 
    transition: all 0.2s; 
}
input:focus { border-color: var(--secondary); box-shadow: 0 0 0 4px rgba(78, 205, 196, 0.2); }
input.shaking { animation: shake 0.5s; border-color: #e74c3c; }

button.magic-btn { 
    background-color: var(--primary); 
    color: white; 
    border: none; 
    padding: 18px 30px; 
    font-size: 1.2rem; 
    border-radius: 15px; 
    cursor: pointer; 
    border-bottom: 5px solid #c0392b; 
    white-space: nowrap;
    transition: all 0.1s;
    flex: 0 0 auto; 
}
button.magic-btn:active { transform: translateY(4px); border-bottom: 0px; }
button.magic-btn:disabled { 
    background-color: #bdc3c7; 
    border-bottom: 5px solid #95a5a6; 
    cursor: not-allowed; 
    transform: none; 
}

/* --- SUGGESTIONS --- */
.suggestions-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 30px;
    align-items: center;
}
.tag-pill {
    background: #edf2f7;
    color: var(--dark);
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    border: 2px solid #e2e8f0;
    transition: all 0.2s;
    user-select: none;
}
.tag-pill:hover {
    background: var(--secondary);
    color: white;
    border-color: var(--secondary);
    transform: translateY(-2px);
}

/* --- CANVAS AREA --- */
#canvas-area { 
    min-height: 500px; 
    background: #fff; 
    border: 4px dashed #cbd5e0; 
    border-radius: 20px; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    flex-direction: column; 
    overflow: hidden; 
    position: relative;
}
img.result { max-width: 100%; max-height: 600px; display: none; }

/* --- ACTIONS --- */
.action-row {
    display: none; 
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}
.action-btn {
    border: none;
    padding: 12px 25px;
    font-size: 1rem;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    color: white;
    transition: transform 0.1s;
    display: flex; align-items: center; gap: 8px;
}
.action-btn:active { transform: scale(0.98); }
.btn-print { background: var(--secondary); }
.btn-download { background: var(--accent); }

/* --- DEBUG BOX --- */
.debug-info { 
    font-size: 0.85rem; 
    color: #666; 
    text-align: left; 
    background: #f1f5f9; 
    padding: 15px; 
    border-radius: 12px; 
    display: none;
    border: 1px solid #e2e8f0; 
}

/* --- DYNAMIC GALLERY GRID --- */
.sidebar-title { 
    font-size: 1.3rem; 
    color: var(--dark); 
    margin-bottom: 15px; 
    font-weight: bold; 
    text-align: left; 
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.gallery-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); 
    gap: 12px; 
    /* Padding right prevents content from touching the scrollbar */
    padding-right: 5px; 
}

.gallery-item { 
    background: white; 
    border: 2px solid #ddd; 
    border-radius: 12px; 
    overflow: hidden; 
    cursor: pointer; 
    transition: all 0.2s; 
    aspect-ratio: 1 / 1; 
    display: flex;
    flex-direction: column;
    /* FIX: Ensure hover doesn't push layout boundaries */
    transform: translateZ(0); 
}
.gallery-item:hover { 
    border-color: var(--secondary); 
    transform: translateY(-3px); 
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}
.gallery-item img { 
    width: 100%; 
    height: 100%; 
    object-fit: contain; 
    padding: 5px; 
    filter: grayscale(100%);
}

@keyframes shake { 
    0%, 100% { transform: translateX(0); } 
    25% { transform: translateX(-8px); } 
    75% { transform: translateX(8px); } 
}

@media print {
    body * { visibility: hidden; }
    #canvas-area, #canvas-area * { visibility: visible; }
    #canvas-area { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border: none; background: white; }
    img.result { width: 100%; height: auto; }
}