/* --- RESET & LAYOUT --- */
body, html { 
    margin: 0; 
    padding: 0; 
    /* FIX 1: Use 'dvh' so buttons don't get covered by browser bars */
    height: 100dvh; 
    width: 100vw;
    font-family: sans-serif; 
    overflow: hidden; 
    
    /* FIX 2: STOP THE 3-FINGER GESTURES / MINIMIZING */
    touch-action: none; 
    overscroll-behavior: none;
}

/* --- COLLAPSIBLE TEACHER SIDEBAR --- */
/* 1. The Wrapper (Invisible box holding the button and menu) */
#teacher-sidebar-container {
    position: fixed;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    z-index: 99999;
    display: flex;
    align-items: center;
    pointer-events: none; /* Let clicks pass through empty space */
}

/* 2. The Toggle Button (The Handle) */
#sidebar-toggle {
    background: #231F20;
    color: white;
    border: none;
    border-radius: 5px 0 0 5px;
    padding: 10px 4px;
    cursor: pointer;
    font-size: 14px;
    pointer-events: auto;
    box-shadow: -2px 2px 5px rgba(0,0,0,0.2);
    margin-right: -1px; /* Connect it seamlessly to the bar */
    transition: background 0.2s;
    height: 40px; /* Easy to click */
}

#sidebar-toggle:hover { background: #2B8447; }

/* 3. The Menu Itself */
#teacher-sidebar-right {
    background: rgba(255, 255, 255, 0.2); /* Semi-transparent */
    backdrop-filter: blur(8px); /* Frosted glass effect */
    padding: 10px 5px;
    border-radius: 0 0 0 12px; /* Rounded bottom-left corner */
    border: 1px solid rgba(255,255,255,0.3);
    border-right: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: auto;
    
    /* SCROLLING MAGIC: Prevents it from getting too tall */
    max-height: 70vh;
    overflow-y: auto;
    
    /* ANIMATION MAGIC: Slides in and out */
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0); /* Default: Visible */
    box-shadow: -4px 4px 10px rgba(0,0,0,0.1);
}

/* 4. The "Hidden" State */
#teacher-sidebar-right.collapsed {
    transform: translateX(110%); /* Slide right out of view */
    box-shadow: none;
}

/* 5. Button Groups */
.tc-group {
    background: rgba(255, 255, 255, 0.3);
    padding: 5px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    border: 1px solid rgba(255,255,255,0.2);
}

/* 6. The Individual Buttons */
.tc-btn {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #999;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.2em;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.2s;
}

.tc-btn:hover { transform: scale(1.15); background: white; z-index: 100; }
.tc-btn:active { transform: scale(0.95); }

/* Colors */
.tc-btn.green { border-bottom: 3px solid #2B8447; }
.tc-btn.gold { border-bottom: 3px solid gold; }
.tc-btn.warn { border-color: #ffcccc; color: #cc0000; }

/* Scrollbar Styling (Hidden but functional) */
#teacher-sidebar-right::-webkit-scrollbar { width: 4px; }
#teacher-sidebar-right::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

/* --- TICKER (Keep this!) --- */
#activity-ticker {
    position: fixed;
    bottom: 45px;
    left: 50%;
    transform: translateX(-50%);
    min-width: 300px;
    padding: 5px 15px;
    background: rgba(35, 31, 32, 0.85);
    color: #fff;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    z-index: 99998;
    border: 1px solid #2B8447;
    pointer-events: none; /* Clicks pass through */
}

#app-container { 
    display: flex; 
    /* FIX 3: Ensure container respects dynamic height */
    height: 100dvh; 
    width: 100vw; 
    overflow: hidden;
}
/* --- SIDEBAR --- */
#sidebar { 
    width: 70px; 
    background: #2c3e50; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    padding: 5px 0; /* Reduced padding */
    z-index: 200; 
    height: 100%; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.2);
    overflow: hidden; 
}
.brand { 
    font-size: 1rem; font-weight: bold; margin-bottom: 5px; 
    color: #ecf0f1; border-bottom: 2px solid #3498db; 
    padding-bottom: 5px; flex-shrink: 0; 
}

/* THE SCROLLABLE CONTAINER */
#tools-container {
    flex: 1; /* Fills the space between Up/Down buttons */
    width: 100%;
    overflow-y: auto; /* Enables scrolling */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 5px;
    
    /* Hide scrollbars */
    -ms-overflow-style: none;  
    scrollbar-width: none;  
}
#tools-container::-webkit-scrollbar { display: none; }

/* ARROW BUTTONS */
.scroll-btn {
    width: 100%; height: 30px;
    background: #34495e; 
    border: none; border-top: 1px solid #456; border-bottom: 1px solid #456;
    color: white; cursor: pointer;
    flex-shrink: 0; z-index: 10;
}
.scroll-btn:active { background: #3498db; }

/* TOOLS */
.tool-btn { 
    width: 44px; height: 44px; 
    background: transparent; border: none; 
    color: #bdc3c7; font-size: 1.2rem; 
    cursor: pointer; border-radius: 8px; 
    transition: all 0.2s; 
    display: flex; justify-content: center; align-items: center;
    flex-shrink: 0; /* Prevents squishing */
}
.tool-btn:hover { background: #34495e; color: white; }
.tool-btn.active { background: #3498db; color: white; box-shadow: 0 0 8px rgba(52, 152, 219, 0.6); }

/* ORANGE MULTI BUTTON */
.tool-btn.multi-active {
    background-color: #ff9800 !important; color: black !important;
    font-weight: bold; box-shadow: 0 0 10px #ff9800; border: 2px solid #e65100;
}

/* FOOTER */
.sidebar-footer { 
    margin-top: 5px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%; 
    background: #2c3e50; 
    padding-top: 5px; 
    border-top: 1px solid #34495e; 
    
    /* Critical: Don't let this shrink, and stay visible */
    flex-shrink: 0; 
    padding-bottom: 5px; /* Tighter padding for tablets */
}

.danger-btn { 
    width: 40px; height: 40px; background: #c0392b; color: white; 
    border: none; border-radius: 5px; font-size: 1rem; cursor: pointer; margin-top: 5px; 
}
hr { width: 30px; border-top: 1px solid #455a64; margin: 5px 0; }

/* --- TOOLS & BUTTONS --- */
.tool-group { 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
}

hr { 
    width: 30px; 
    border-top: 1px solid #455a64; 
    margin: 5px 0; 
}

.tool-btn { 
    width: 44px; 
    height: 44px; 
    background: transparent; 
    border: none; 
    color: #bdc3c7; 
    font-size: 1.2rem; 
    cursor: pointer; 
    border-radius: 8px; 
    margin-bottom: 5px; 
    transition: all 0.2s; 
    display: flex; 
    justify-content: center; 
    align-items: center;
}

.tool-btn:hover { background: #34495e; color: white; }

.tool-btn.active { 
    background: #3498db; 
    color: white; 
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.6); 
}

/* MULTI-TOUCH ORANGE BUTTON */
.tool-btn.multi-active {
    background-color: #ff9800 !important; /* Safety Orange */
    color: black !important;
    font-weight: bold;
    box-shadow: 0 0 10px #ff9800;
    border: 2px solid #e65100;
}

/* FOOTER (Undo/Redo area) */
.sidebar-footer { 
    margin-top: 5px; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    width: 100%;
    background: #2c3e50; /* Covers content if scrolling happens behind it */
    padding-top: 5px;
    border-top: 1px solid #34495e;
}

.danger-btn { 
    width: 40px; height: 40px; 
    background: #c0392b; 
    color: white; border: none; 
    border-radius: 5px; font-size: 1rem; 
    cursor: pointer; margin-top: 5px; 
}

/* --- MAIN STAGE (Unchanged) --- */
#main-stage {
    flex-grow: 1;
    position: relative;
    background: #333;
    display: flex;
    flex-direction: column; /* Stacks Zoom Container on top of Bottom Bar */
    overflow: hidden; 
    height: 100%; /* Fill the remaining height */
}
#zoom-container {
    flex-grow: 1;
    width: 100%;
    height: 100%;
    
    /* ALIGNMENT: Top-Left */
    display: flex;
    justify-content: flex-start; /* Horizontal: Left */
    align-items: flex-start;     /* Vertical: Top (This was 'center') */
    
    padding: 20px; /* Adds nice spacing from the top and left edges */
    overflow: auto; 
    touch-action: none;
}

/* Ensure the wrapper positions its children correctly */
#canvas-wrapper {
    position: relative;
    width: 960px;
    height: 540px;
    background: white;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    transition: transform 0.1s ease-out;
    transform-origin: top left; 
    margin: 0; 
}

/* FIX: Force the Google Slide to fill the wrapper */
#slide-frame {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
    z-index: 1; /* Bottom layer */
}

/* FIX: Ensure the Drawing Layer sits ON TOP of the slide */
.canvas-container {
    position: absolute !important;
    top: 0;
    left: 0;
    z-index: 10; /* Top layer */
}
#bottom-bar { 
    height: 50px; background: white; 
    display: flex; align-items: center; justify-content: space-between; 
    padding: 0 20px; z-index: 100; border-top: 1px solid #ccc; 
}
.nav-group { display: flex; align-items: center; gap: 10px; }

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}