/* ============================================================
   Tkinter Masterclass — Main Stylesheet
   css/styles.css
   ============================================================ */

/* --- CSS VARIABLES & THEME --- */
:root {
    --bg-body: #f5f5f7;
    --bg-slide: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --accent: #0071e3;
    --accent-hover: #0077ed;
    --code-bg: #1e1e1e;
    --code-text: #d4d4d4;
    --border: #d2d2d7;
    --shadow: 0 4px 24px rgba(0,0,0,0.06);
    --tkinter-gray: #ececec;
    --tkinter-blue: #e1f0ff;
    --font-main: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: "SF Mono", "Menlo", "Monaco", "Courier New", monospace;
    --transition-speed: 0.4s;
}

[data-theme="dark"] {
    --bg-body: #121212;
    --bg-slide: #1c1c1e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --accent: #2997ff;
    --accent-hover: #0071e3;
    --code-bg: #000000;
    --border: #38383a;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --tkinter-gray: #2c2c2e;
    --tkinter-blue: #0a2a4a;
}

/* --- RESET & BASE --- */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-main);
    background-color: var(--bg-body);
    color: var(--text-primary);
    /* dvh accounts for mobile browser address bar; vh is the fallback for older browsers */
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: background-color var(--transition-speed), color var(--transition-speed);
    display: flex;
    flex-direction: column;
}

/* --- LAYOUT --- */
header {
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-slide);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-shrink: 0;
}

.logo { font-weight: 700; font-size: 1.2rem; display: flex; align-items: center; gap: 8px; }
.logo svg { width: 24px; height: 24px; fill: var(--accent); }
.logo img {
    height: 1.2em;
    width: auto;
    object-fit: contain;
}
.controls-top { display: flex; gap: 1rem; align-items: center; }

button.theme-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-primary); font-size: 1.2rem; transition: transform 0.2s;
}
button.theme-toggle:hover { transform: scale(1.1); }

.progress-container {
    position: absolute; top: 0; left: 0;
    width: 100%; height: 4px; background: transparent; z-index: 101;
}
.progress-bar { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s ease; }

main { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }

/* --- SLIDES SYSTEM --- */
.slides-wrapper { width: 100%; height: 100%; position: relative; }

section.slide {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    padding: 2rem 3rem; opacity: 0; transform: translateY(20px);
    pointer-events: none; transition: opacity 0.5s ease, transform 0.5s ease;
    display: flex; flex-direction: column;
    overflow-y: auto;
    align-items: center;
}
section.slide.active { opacity: 1; transform: translateY(0); pointer-events: all; z-index: 10; }

/* --- SPLIT LAYOUT --- */
.split-layout {
    display: flex;
    flex-direction: column;
    gap: 30px;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    align-items: stretch;
}

.left-col { width: 100%; }
.right-col { width: 100%; display: flex; flex-direction: column; gap: 20px; }

/* --- TYPOGRAPHY --- */
h1 { font-size: 2.5rem; margin-bottom: 0.5rem; letter-spacing: -0.02em; line-height: 1.1; text-align: center; }
h2 { font-size: 1.8rem; margin-bottom: 1rem; color: var(--accent); margin-top: 20px; }
h3 { font-size: 1.15rem; margin-bottom: 0.5rem; color: var(--text-primary); margin-top: 1rem; }
p, li { font-size: 1rem; line-height: 1.6; color: var(--text-secondary); margin-bottom: 0.8rem; text-align: left; }
ul, ol { margin-left: 1.5rem; margin-bottom: 1rem; text-align: left; }
li { margin-bottom: 0.4rem; }
code {
    background: rgba(128,128,128,0.15); padding: 2px 5px;
    border-radius: 4px; font-family: var(--font-mono); font-size: 0.9em; color: var(--accent);
}

.info-box {
    background: var(--tkinter-blue); border-left: 4px solid var(--accent);
    padding: 15px; border-radius: 4px; margin: 15px 0; width: 100%; text-align: left;
}

/* --- CODE BLOCKS --- */
.code-window {
    background: var(--code-bg); border-radius: 12px; padding: 0.8rem;
    box-shadow: var(--shadow); font-family: var(--font-mono); font-size: 0.85rem;
    color: var(--code-text); position: relative; overflow-x: auto;
    border: 1px solid var(--border); margin-top: 10px; width: 100%;
}
/*.code-window::before {*/
/*    content: '● ● ●'; position: absolute; top: 10px; left: 15px;*/
/*    color: #555; font-size: 0.8rem; letter-spacing: 2px;*/
/*}*/
.code-content { margin-top: 2rem; white-space: pre; line-height: 1.5; }

/* Syntax Highlighting */
.kw   { color: #569cd6; }
.str  { color: #ce9178; }
.func { color: #dcdcaa; }
.com  { color: #6a9955; }
.num  { color: #b5cea8; }
.cls  { color: #4ec9b0; }

/* --- DEMO AREA --- */
.demo-area {
    background: var(--bg-slide); border: 2px dashed var(--border);
    border-radius: 12px; padding: 2rem; min-height: 200px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    position: relative; box-shadow: inset 0 0 20px rgba(0,0,0,0.02);
    width: 100%; margin: 0 auto;
}

/* --- TKINTER SIMULATION WIDGETS --- */
.tk-btn {
    background: var(--tkinter-gray); border: 1px solid #999;
    padding: 6px 16px; cursor: pointer; font-family: sans-serif;
    font-size: 13px; border-radius: 4px; transition: background 0.1s; margin: 5px;
}
.tk-btn:active { background: #bbb; }
.tk-entry { border: 1px solid #999; padding: 5px; font-family: sans-serif; background: white; color: black; border-radius: 3px; margin: 5px; }
.tk-label { font-family: sans-serif; font-size: 13px; margin: 5px; }

/* --- NAVIGATION --- */
footer {
    padding: 1rem 2rem; background: var(--bg-slide); border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    z-index: 100; flex-shrink: 0;
}
.nav-btn {
    background: var(--bg-body); border: 1px solid var(--border); color: var(--text-primary);
    padding: 0.8rem 1.5rem; border-radius: 30px; cursor: pointer; font-weight: 600;
    transition: all 0.2s; display: flex; align-items: center; gap: 8px;
}
.nav-btn:hover { background: var(--border); transform: translateY(-2px); }
.nav-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.slide-counter { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-weight: 600; }

/* --- WIDGET-SPECIFIC STYLES --- */

/* Notebook / Tabs */
.notebook { width: 100%; border: 1px solid #999; background: #f0f0f0; height: 200px; }
.tabs { display: flex; background: #d9d9d9; }
.tab { padding: 5px 15px; cursor: pointer; border-top-left-radius: 4px; border-top-right-radius: 4px; border: 1px solid #d9d9d9; border-bottom: none; font-size: 12px; }
.tab.active { background: #f0f0f0; border: 1px solid #999; border-bottom: 1px solid #f0f0f0; margin-bottom: -1px; position: relative; }
.tab-content { padding: 15px; height: 100%; display: none; }
.tab-content.active { display: block; }

/* Listbox */
.listbox-demo { border: 1px solid #999; background: white; height: 120px; width: 100%; max-width: 300px; overflow-y: auto; font-family: sans-serif; font-size: 13px; }
.list-item { padding: 2px 5px; cursor: pointer; }
.list-item:hover { background: #e1f0ff; }
.list-item.selected { background: var(--accent); color: white; }

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; display: none; justify-content: center; align-items: center; }
.modal { background: #f0f0f0; width: 300px; border: 1px solid #999; box-shadow: 4px 4px 10px rgba(0,0,0,0.2); font-family: 'Segoe UI', sans-serif; }
.modal-header { background: #fff; padding: 5px; font-weight: bold; display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #ccc; }
.modal-body { padding: 20px; text-align: center; color: black; }
.modal-footer { padding: 10px; text-align: center; background: #f0f0f0; border-top: 1px solid #ccc; }

/* Calculator */
.calc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; background: #333; padding: 10px; border-radius: 8px; width: 220px; }
.calc-display { grid-column: span 4; background: #444; color: white; font-size: 24px; text-align: right; padding: 10px; margin-bottom: 5px; font-family: monospace; border-radius: 4px; }
.calc-btn { padding: 15px; border: none; background: #555; color: white; cursor: pointer; font-size: 16px; border-radius: 4px; }
.calc-btn.op { background: var(--accent); }
.calc-btn.eq { background: #4CAF50; }

/* Responsive / Resizable Frame Demo */
.resizable-window {
    width: 100%; height: 250px; border: 4px solid #555; background: #fff;
    display: flex; flex-direction: column; overflow: hidden;
    resize: both; min-width: 200px; min-height: 150px; max-width: 100%;
    box-shadow: var(--shadow);
}
.frame-top { background: #ffcccc; padding: 10px; text-align: center; flex-shrink: 0; }
.frame-body { display: flex; flex: 1; overflow: hidden; }
.frame-side { background: #ccffcc; width: 100px; flex-shrink: 0; padding: 10px; writing-mode: vertical-rl; text-orientation: mixed; text-align: center; }
.frame-main { background: #ccccff; flex: 1; padding: 10px; display: flex; align-items: center; justify-content: center; }

/* Billing App */
.billing-app { width: 100%; height: 100%; display: flex; flex-direction: column; background: white; border: 1px solid #999; }
.bill-header { background: #f0f0f0; padding: 10px; border-bottom: 1px solid #ccc; display: flex; justify-content: space-between; }
.bill-body { display: flex; flex: 1; overflow: hidden; }
.bill-inputs { padding: 10px; width: 220px; border-right: 1px solid #ccc; background: #fafafa; display: flex; flex-direction: column; gap: 8px; }
.bill-list { flex: 1; overflow-y: auto; padding: 10px; }
.bill-row { display: flex; justify-content: space-between; border-bottom: 1px dashed #ccc; padding: 4px 0; font-size: 12px; font-family: sans-serif; }

/* Menu Demo */
.menu-demo { width: 100%; border: 1px solid #999; background: white; font-family: sans-serif; min-height: 150px; }
.menubar { display: flex; background: #f0f0f0; border-bottom: 1px solid #999; padding: 2px 5px; }
.menu-item { padding: 2px 10px; cursor: pointer; font-size: 13px; position: relative; }
.menu-item:hover { background: var(--tkinter-blue); }
.dropdown { position: absolute; top: 100%; left: 0; background: white; border: 1px solid #999; display: none; flex-direction: column; min-width: 150px; box-shadow: 2px 2px 5px rgba(0,0,0,0.1); z-index: 20; }
.dropdown-item { padding: 5px 20px; cursor: pointer; font-size: 13px; }
.dropdown-item:hover { background: var(--tkinter-blue); }
.menu-item:hover .dropdown { display: flex; }

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }


/* --- NAVIGATION DRAWER --- */

/* Hamburger button in header */
.drawer-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--text-primary); font-size: 1.4rem;
    display: flex; flex-direction: column; justify-content: center;
    gap: 5px; padding: 4px; transition: transform 0.2s;
}
.drawer-toggle:hover { transform: scale(1.1); }
.drawer-toggle span {
    display: block; width: 22px; height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: transform 0.3s ease, opacity 0.3s ease;
}
/* Animate into X when open */
.drawer-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.drawer-toggle.open span:nth-child(2) { opacity: 0; }
.drawer-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Dark overlay behind drawer */
.drawer-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 200;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }

/* Drawer panel */
.drawer {
    position: fixed; top: 0; left: 0;
    width: 280px; height: 100%;
    background: var(--bg-slide);
    border-right: 1px solid var(--border);
    z-index: 201;
    display: flex; flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}
.drawer.open { transform: translateX(0); }

/* Drawer header */
.drawer-header {
    padding: 1.1rem 1.2rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.drawer-header h3 {
    font-size: 0.95rem; font-weight: 700;
    color: var(--text-primary); margin: 0;
    text-transform: uppercase; letter-spacing: 0.06em;
}
.drawer-close {
    background: none; border: none; cursor: pointer;
    color: var(--text-secondary); font-size: 1.3rem; line-height: 1;
    padding: 2px 6px; border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.drawer-close:hover { background: var(--border); color: var(--text-primary); }

/* Scrollable slide list */
.drawer-list {
    flex: 1; overflow-y: auto;
    padding: 0.5rem 0;
}

/* Module group label */
.drawer-module {
    padding: 0.6rem 1.2rem 0.2rem;
    font-size: 0.7rem; font-weight: 700;
    color: var(--accent);
    text-transform: uppercase; letter-spacing: 0.08em;
    margin-top: 0.4rem;
}

/* Individual slide link */
.drawer-item {
    display: flex; align-items: center; gap: 10px;
    padding: 0.55rem 1.2rem;
    cursor: pointer;
    border: none; background: none; width: 100%;
    text-align: left; color: var(--text-secondary);
    font-size: 0.88rem; font-family: var(--font-main);
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.drawer-item:hover {
    background: var(--tkinter-blue);
    color: var(--text-primary);
}
.drawer-item.active {
    color: var(--accent);
    font-weight: 600;
    border-left-color: var(--accent);
    background: var(--tkinter-blue);
}
.drawer-item .slide-num {
    font-size: 0.72rem; font-weight: 700;
    color: var(--text-secondary);
    min-width: 22px; text-align: right;
    opacity: 0.6;
}
.drawer-item.active .slide-num { color: var(--accent); opacity: 1; }


@media (max-width: 600px) {
    /* Shrink header so slides and footer have more room */
    header { padding: 0.6rem 1rem; }
    .logo  { font-size: 1rem; }

    /* Compact slide padding */
    section.slide { padding: 1rem 1.2rem; }

    /* Compact footer — this is the main fix for the hidden footer bug */
    footer { padding: 0.5rem 0.8rem; }

    /* Smaller nav buttons so they fit on narrow screens */
    .nav-btn {
        padding: 0.55rem 1rem;
        font-size: 0.85rem;
        border-radius: 20px;
    }

    .slide-counter { font-size: 0.85rem; }

    /* Reduce heading sizes so content fits without pushing footer off-screen */
    h1 { font-size: 1.6rem; }
    h2 { font-size: 1.3rem; margin-top: 10px; }
    h3 { font-size: 1rem; }
    p, li { font-size: 0.9rem; }

    /* Code blocks: smaller font so they don't overflow */
    .code-window { font-size: 0.75rem; }
}
