/* ==========================================================================
   1. Design Tokens & Core Theme Framework
   ========================================================================== */
:root {
    --primary-green: #16a34a;
    --primary-green-hover: #15803d;
    --primary-blue: #2563eb;
    --danger-red: #dc2626;
    --danger-red-hover: #b91c1c;
    
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-color: #1e293b;
    --subtle-text: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

body.dark-mode {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f8fafc;
    --subtle-text: #94a3b8;
    --border-color: #334155;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}


/* ==========================================================================
   2. Master Global Element Overrides
   ========================================================================== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

body { 
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-color); 
    color: var(--text-color); 
    display: flex;
    flex-direction: column;
    transition: background 0.25s ease, color 0.25s ease;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: stretch;
    padding: 160px 20px 60px 20px;
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

section {
    width: 100%;
    max-width: 850px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

h2 { margin: 0; font-weight: 700; color: var(--text-color); }


/* ==========================================================================
   3. Extensible Button Styles & Micro-interactions
   ========================================================================== */
button { 
    color: white; 
    border: none; 
    padding: 10px 18px; 
    border-radius: 8px; 
    cursor: pointer; 
    font-weight: 600;
    font-size: 0.95rem;
    transition: background 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

button:active { transform: scale(0.98); }

.btn-success { background: var(--primary-green); }
.btn-success:hover { background: var(--primary-green-hover); }

.btn-secondary { background: var(--primary-blue); }
.btn-secondary:hover { background: #1d4ed8; }

.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-color); }
.btn-outline:hover { background: var(--bg-color); }

.delete-btn { background: var(--danger-red); padding: 6px 12px; font-size: 0.85rem; }
.delete-btn:hover { background: var(--danger-red-hover); }


/* ==========================================================================
   4. Application Shell Layout Components
   ========================================================================== */
header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 14px 40px; 
    position: fixed; 
    top: 0; 
    width: 100%; 
    box-sizing: border-box; 
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-left { display: flex; align-items: center; gap: 12px; }
.brand-name { font-weight: 700; font-size: 1.35rem; color: var(--text-color); letter-spacing: -0.02em; }
.logo-gif { width: 128px; height: 128px; object-fit: cover; border-radius: 12px;}

.header-nav { display: flex; gap: 28px; font-weight: 600; color: var(--subtle-text); }
.header-nav span { cursor: pointer; transition: color 0.2s; }
.header-nav span:hover { color: var(--primary-green); }

.hamburger { background: none; color: var(--text-color); font-size: 24px; padding: 0; }
.hamburger:hover { color: var(--primary-blue); }

.hidden-on-login { display: none !important; }

footer { 
    text-align: center; 
    padding: 15px; 
    color: var(--subtle-text); 
    font-size: 0.85rem; 
    position: fixed; 
    bottom: 0; 
    width: 100%; 
    box-sizing: border-box;
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    z-index: 90;
}


/* ==========================================================================
   5. Authentication Intermediary Card UI
   ========================================================================== */
.center-login { display: flex; flex-direction: column; align-items: center; max-width: 420px; margin: auto; }
.login-header { text-align: center; margin-bottom: 25px; }

.icon-box {
    background-color: var(--primary-green);
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 16px auto;
}

.login-header h2 { font-size: 1.85rem; margin-bottom: 4px; }
.login-header p { font-size: 0.95rem; color: var(--subtle-text); margin: 0; }

.login-card {
    background: var(--card-bg);
    padding: 35px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border: 1px solid var(--border-color);
}

.input-group label { display: block; margin-bottom: 6px; color: var(--text-color); font-weight: 600; font-size: 0.9rem; }
.input-container { position: relative; display: flex; align-items: center; width: 100%; }

.input-container input {
    width: 100%;
    padding: 12px 12px 12px 42px;
    margin: 0;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-color);
    border-radius: 8px;
    font-size: 0.95rem;
    box-sizing: border-box;
}

.input-container input:focus { border-color: var(--primary-blue); outline: none; }
.icon-leading { position: absolute; left: 14px; color: var(--subtle-text); pointer-events: none; }

.login-btn-large { background: var(--primary-green); padding: 14px; border-radius: 8px; font-weight: 700; font-size: 1rem; width: 100%; margin-top: 5px; }
.login-btn-large:hover { background: var(--primary-green-hover); }


/* ==========================================================================
   6. Sliding Aside Panel Engine
   ========================================================================== */
.drawer-backdrop { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 23, 42, 0.4); z-index: 101; }
.drawer {
    position: fixed; top: 0; height: 100%; width: 300px; background: var(--card-bg);
    box-shadow: -10px 0 25px -5px rgba(0, 0, 0, 0.1), -4px 0 10px -5px rgba(0, 0, 0, 0.04);
    z-index: 102; display: flex; flex-direction: column; transition: right 0.25s cubic-bezier(0.4, 0, 0.2, 1); box-sizing: border-box; padding: 30px 24px;
    border-left: 1px solid var(--border-color);
}

.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 32px; }
.drawer-header h3 { margin: 0; font-size: 1.25rem; color: var(--text-color); }
.close-btn { background: none; color: var(--subtle-text); font-size: 26px; padding: 0; }
.close-btn:hover { color: var(--text-color); }

.drawer-links { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.drawer-item { display: flex; align-items: center; gap: 14px; font-weight: 600; color: var(--text-color); cursor: pointer; padding: 12px 10px; border-radius: 8px; }
.drawer-item:hover { color: var(--primary-green); background: var(--bg-color); }
.drawer-footer { display: flex; align-items: center; gap: 14px; color: var(--danger-red); font-weight: 600; cursor: pointer; margin-top: auto; padding: 12px 10px; border-radius: 8px; }
.drawer-footer:hover { background: #fee2e2; }


/* ==========================================================================
   7. Dashboard Framework Component Models
   ========================================================================== */
.library-header-row { flex-shrink: 0; display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-title { font-size: 2rem; letter-spacing: -0.03em; }
.sub-text { margin: 4px 0 0 0; color: var(--subtle-text); font-size: 0.95rem; }

.search-container { flex-shrink: 0; }
.search-container input { width: 100%; padding: 14px 16px; border-radius: 10px; border: 1px solid var(--border-color); margin-bottom: 20px; box-sizing: border-box; background: var(--card-bg); color: var(--text-color); }

.card-list { 
    flex: 1; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 12px; 
    padding-right: 6px;
    margin-bottom: 20px;
}

.game-card {
    background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px;
    padding: 20px 24px; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow);
    flex-shrink: 0;
}

.card-details h4 { margin: 0 0 6px 0; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.badge { font-size: 0.75rem; padding: 3px 10px; border-radius: 99px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.badge.draft { color: #b45309; background: #fef3c7; }
.badge.ready { color: #15803d; background: #dcfce7; }
.badge.quiz { color: var(--primary-blue); background: #dbeafe; }
.badge.survey { color: #7c3aed; background: #f3e8ff; }
.badge.poll { color: #0891b2; background: #ecfeff; }

.card-actions { display: flex; gap: 18px; align-items: center; }
.action-icon { cursor: pointer; font-size: 1.25rem; transition: transform 0.1s; user-select: none; }
.action-icon:hover { transform: scale(1.15); }


/* ==========================================================================
   8. Deep Nested Editor Structuring
   ========================================================================== */
#editorPanel { 
    max-width: 850px; 
    background: var(--card-bg); 
    padding: 30px 35px 85px 35px; /* 👈 Extra 85px bottom padding explicitly safeguards the footer space */
    border-radius: 16px; 
    box-shadow: var(--shadow); 
    border: 1px solid var(--border-color);
    position: relative;           /* 👈 Crucial: Anchors the action footer to the card frame */
    height: calc(100vh - 240px);  /* Strictly locks the card height inside the screen view */
    box-sizing: border-box;
    overflow: hidden;             /* Keeps layout spills contained */
}

.editor-scroll-body {
    height: 100%;                 /* 👈 Forces the scrolling block to fill the exact card cavity */
    overflow-y: auto;             /* 👈 Guarantees your native vertical scrollbar triggers */
    padding-right: 6px;
    box-sizing: border-box;
}

.editor-header-row { display: flex; flex-direction: column; gap: 20px; margin-bottom: 25px; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; }
.editor-meta-controls { display: flex; gap: 15px; width: 100%; }
.editor-meta-controls input { margin: 0; flex: 2; }
.editor-meta-controls select { margin: 0; flex: 1; }

.q-box { background: var(--bg-color); border: 1px solid var(--border-color); padding: 24px; margin: 20px 0; border-radius: 12px; display: flex; flex-direction: column; gap: 14px; }
.q-header { display: flex; justify-content: space-between; align-items: center; font-size: 1.05rem; }
.q-box > input { margin: 0; padding: 12px; font-weight: 500; }

.options-grid { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.option-row { display: flex; gap: 12px; width: 100%; }
.option-row input { margin: 0; padding: 10px 12px; font-size: 0.9rem; }
.option-row input[type="text"]:first-child { flex: 3; }
.option-row input[type="text"]:last-child { flex: 1; }

.editor-actions-footer { 
    position: absolute;           /* 👈 Pin directly to the bottom of the main frame */
    bottom: 0;
    left: 35px;                   /* Perfectly matches the parent panel's left padding boundary */
    right: 35px;                  /* Perfectly matches the parent panel's right padding boundary */
    height: 80px;                 /* Uniform fixed height zone */
    background: var(--card-bg);
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    border-top: 1px solid var(--border-color); 
    z-index: 10;
    box-sizing: border-box;
}
.right-actions { display: flex; gap: 12px; }