/* =========================================
   🎨 1. ตัวแปรสีหลักของระบบ (Google AI Studio Theme)
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    /* 🌌 โทนสีเข้มพรีเมียม สไตล์ Google AI Studio Workspace */
    --bg-canvas: #0b0f19; 
    --line-color: rgba(255, 255, 255, 0.08); 
    --card-bg-child: #161e2e; 
    --text-main: #f1f5f9;
    --text-muted: #8ba3c7;
    --header-bg: rgba(11, 15, 25, 0.85);
    --border-color: rgba(255, 255, 255, 0.1);

    /* 🔄 Polarity Inversion (การสลับสีกลับขั้ว) */
    --inv-bg: #f8fafc;
    --inv-header-bg: rgba(0, 0, 0, 0.04);
    --inv-text-main: #0f172a;
    --inv-text-muted: #475569;
    
    /* 💻 Popup Modals (Light Theme สว่างสะอาดตา) */
    --code-bg-inv: #ffffff;
    --code-line-bg-inv: #f8fafc;
    --code-text-inv: #1e293b; 
    --code-header-inv: #f1f5f9;
    --code-border-inv: #e2e8f0;

    --font-family: 'Sarabun', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background-color: var(--bg-canvas); 
    color: var(--text-main);
    font-family: var(--font-family); 
    margin: 0; padding: 0;
    height: 100vh; 
    display: flex; 
    flex-direction: column;
    overflow: hidden; 
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139, 163, 199, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(139, 163, 199, 0.6); }

/* =========================================
   🌌 2. Fluid Ambient Background (คลื่นแสงเหลว)
   ========================================= */
.ambient-fluid-bg {
    position: fixed; inset: 0; z-index: 0; 
    display: flex; place-content: center; align-items: center; overflow: hidden;
    background-color: #0b0f19; opacity: 0; transition: opacity 1.2s ease-in-out; pointer-events: none; 
}
body.hologram-mode-active .ambient-fluid-bg { opacity: 1; }

@keyframes rotateGradient {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

.gradient {
    --size: 1000px; --speed: 40s; --easing: cubic-bezier(0.8, 0.2, 0.2, 0.8);
    width: var(--size); height: var(--size); filter: blur(calc(var(--size) / 5));
    background-image: linear-gradient(#4377ef, #7befd0); 
    animation: rotateGradient var(--speed) var(--easing) alternate infinite;
    border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;
    position: absolute; top: 50%; left: 50%; opacity: 0.35; 
}
@media (min-width: 720px) { .gradient { --size: 850px; } }

/* =========================================
   📊 3. Dashboard Header & Buttons
   ========================================= */
.dashboard-header {
    position: fixed; top: 0; left: 0; right: 0; height: 70px;
    background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center;
    padding: 0 40px; z-index: 1000; box-shadow: 0 4px 30px rgba(0,0,0,0.2);
}
.dash-brand { display: flex; align-items: center; gap: 12px; }
.dash-titles h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text-main); letter-spacing: 0.5px; }
.badge { font-size: 12px; background: rgba(255,255,255,0.1); padding: 4px 10px; border-radius: 12px; color: #7befd0; font-weight: bold; border: 1px solid rgba(123, 239, 208, 0.3);}
.dash-right-controls { display: flex; align-items: center; gap: 20px; }
.dash-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); }

.theme-switch-wrapper { display: flex; align-items: center; gap: 8px; background: rgba(0,0,0,0.2); padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border-color);}
.theme-switch-wrapper .material-symbols-outlined { font-size: 20px; color: var(--text-muted); }
.theme-switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #cbd5e1; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: #0081cf; } 
input:checked + .slider:before { transform: translateX(18px); }
.slider.round { border-radius: 20px; }
.slider.round:before { border-radius: 50%; }

.sync-btn, .recycle-btn {
    padding: 6px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 6px; font-family: var(--font-family); font-weight: 500; font-size: 13px; transition: all 0.2s ease;
}
.sync-btn { background: rgba(0, 129, 207, 0.15); border: 1px solid rgba(0, 129, 207, 0.4); color: #7befd0; }
.sync-btn:hover { background: rgba(0, 129, 207, 0.3); color: #ffffff; border-color: #0081cf; transform: translateY(-1px); }
.recycle-btn { background: rgba(244, 63, 94, 0.1); border: 1px solid rgba(244, 63, 94, 0.3); color: #fb7185; }
.recycle-btn:hover { background: rgba(244, 63, 94, 0.25); color: #ffffff; border-color: #f43f5e; }
.sync-icon.spinning { animation: spin-sync 1s linear infinite; }
@keyframes spin-sync { 100% { transform: rotate(360deg); } }
.meta-divider { color: var(--line-color); margin: 0 4px; }

/* =========================================
   📐 4. Main Area & Tree Layout (Backbone Network)
   ========================================= */
.sitemap-main { flex-grow: 1; overflow: auto; padding: 100px 0 50px 0; width: 100%; position: relative; z-index: 10;}
.tree-container { display: flex; flex-direction: column; align-items: center; position: relative; width: 95%; margin: 0 auto; }
.tree-branches { display: flex; justify-content: center; gap: 20px; position: relative; padding-top: 30px; }

.tree-branches::before { content: ''; position: absolute; top: 0; left: 125px; right: 125px; border-top: 2px dashed var(--line-color); z-index: 0; }
.tree-branches::after { content: ''; position: absolute; top: -30px; left: 50%; transform: translateX(-50%); height: 30px; border-left: 2px dashed var(--line-color); z-index: 0; }
.tree-column { display: flex; flex-direction: column; align-items: center; position: relative; width: 250px; z-index: 1;}
.tree-column::before { content: ''; position: absolute; top: -30px; left: 50%; transform: translateX(-50%); height: 30px; border-left: 2px dashed var(--line-color); z-index: 0; }

/* 🌟 กู้คืนสายสัญญาณแนวตั้งหลักระหว่างโหนดของระบบ (แก้ปัญหาเส้นขาด) */
.files-wrapper { display: flex; flex-direction: column; align-items: center; width: 100%; margin-top: 30px; position: relative; }
.files-wrapper::before { 
    content: ''; position: absolute; top: -40px; bottom: 30px; left: 50%; transform: translateX(-50%); 
    width: 2px; background-image: linear-gradient(to bottom, var(--line-color) 50%, transparent 50%); 
    background-size: 2px 14px; background-repeat: repeat-y; z-index: -1; 
}

/* =========================================
   ⚡ ท่อส่งสัญญานและไฟวิ่ง (Routing Flow)
   ========================================= */

@keyframes flowUp { 0% { background-position: 0 16px; } 100% { background-position: 0 0; } }
@keyframes flowDown { 0% { background-position: 0 0; } 100% { background-position: 0 16px; } }
@keyframes flowLeft { 0% { background-position: 0 0; } 100% { background-position: -16px 0; } }
@keyframes flowRight { 0% { background-position: 0 0; } 100% { background-position: 16px 0; } }

/* --- 🔥 เส้นไฟวิ่งมาตรฐานเมื่อขยายการ์ดโหมดปกติ (Tree Active Path) --- */
.tree-container.has-active-path .tree-branches::after { border-left: none !important; width: 3px; background-image: linear-gradient(to bottom, var(--active-glow-color) 50%, transparent 50%); background-size: 3px 16px; background-repeat: repeat-y; box-shadow: 0 0 12px var(--active-glow-color); animation: flowDown 0.5s linear infinite; z-index: 2; }
.active-h-line { position: absolute; top: -1.5px; height: 3px; box-shadow: 0 0 12px var(--active-glow-color); z-index: 2; opacity: 0; transition: opacity 0.3s ease; }
.active-h-line.flow-left { background-image: linear-gradient(to left, var(--active-glow-color) 50%, transparent 50%); background-size: 16px 3px; animation: flowLeft 0.5s linear infinite; }
.active-h-line.flow-right { background-image: linear-gradient(to right, var(--active-glow-color) 50%, transparent 50%); background-size: 16px 3px; animation: flowRight 0.5s linear infinite; }
.tree-column.active-path::before { border-left: 3px dashed var(--theme-color); box-shadow: -2px 0 10px var(--theme-color); z-index: 2;}

/* --- 🌟 เส้นทาง Routing Flow สีขาวของการกดแท็ก --- */
.active-h-line.routing-flow { box-shadow: 0 0 15px var(--flow-color); opacity: 1; z-index: 3;}
.active-h-line.routing-flow.flow-left { background-image: linear-gradient(to left, var(--flow-color) 50%, transparent 50%); animation: flowLeft 0.3s linear infinite; }
.active-h-line.routing-flow.flow-right { background-image: linear-gradient(to right, var(--flow-color) 50%, transparent 50%); animation: flowRight 0.3s linear infinite; }

/* เส้นแนวดิ่งทับซ้อน */
.tree-column.routing-path::before { border-left: 3px dashed #ffffff !important; box-shadow: -2px 0 12px #ffffff !important; z-index: 3;}
.tree-column.routing-path .files-wrapper::before { 
    width: 3px; 
    background-image: linear-gradient(to bottom, #ffffff 50%, transparent 50%) !important; 
    background-size: 3px 16px; 
    box-shadow: 0 0 12px #ffffff !important; 
    z-index: 2; /* สำคัญ: ให้อยู่ใต้การ์ด (.node-card) */
}

/* กำหนดทิศทางไฟวิ่งของเสาแนวดิ่ง */
.tree-column.routing-path.flow-up .files-wrapper::before { animation: flowUp 0.3s linear infinite !important; }
.tree-column.routing-path.flow-down .files-wrapper::before { animation: flowDown 0.3s linear infinite !important; }


/* =========================================
   📊 5. Bento Card Design
   ========================================= */
.root-stats-card {
    background: linear-gradient(145deg, rgba(22, 30, 46, 0.95), rgba(11, 15, 25, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border-radius: 20px; padding: 30px 40px; 
    display: grid; grid-template-columns: 1.5fr 1fr 2fr; align-items: center;
    width: 760px; box-shadow: 0 25px 50px rgba(0,0,0,0.5); 
    position: relative; z-index: 10; margin-bottom: 40px; 
    border-top: 4px solid #0081cf;
}
.root-brand-block { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.root-brand-main { font-size: 28px; font-weight: 800; background: linear-gradient(to right, #ffffff, #8ba3c7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin: 0; line-height: 1; letter-spacing: -0.5px;}
.root-brand-sub { font-size: 13px; font-weight: 600; color: #7befd0; margin: 0; text-transform: uppercase; letter-spacing: 1px; }

.root-chart-block { display: flex; justify-content: center; align-items: center; position: relative; }
.root-chart-block::before { content: ''; position: absolute; width: 90px; height: 90px; border-radius: 50%; background: #0081cf; filter: blur(25px); opacity: 0.3; z-index: -1;}
.root-donut-chart { width: 80px; height: 80px; border-radius: 50%; background: conic-gradient(#0081cf var(--total-pct), rgba(255,255,255,0.05) 0); display: flex; align-items: center; justify-content: center; }
.root-donut-hole { width: 62px; height: 62px; border-radius: 50%; background-color: #0b0f19; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; box-shadow: inset 0 4px 10px rgba(0,0,0,0.5); }
.root-donut-val { font-size: 20px; font-weight: 800; color: #ffffff; }
.root-donut-lbl { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-top: 2px;}

.root-stats-block { display: flex; justify-content: space-around; align-items: center; background: rgba(0,0,0,0.2); padding: 15px 20px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.05); }
.root-stat-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.root-stat-icon { font-size: 24px; color: var(--text-muted); }
.root-stat-value { font-size: 24px; font-weight: 700; font-family: 'Consolas', monospace; color: var(--text-main); line-height: 1; }
.root-stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}
.root-stat-divider { width: 1px; height: 50px; background-color: rgba(255,255,255,0.1); }

/* 🌟 ตั้งค่าให้การ์ดลูกลอยขึ้นมาอยู่ระนาบหน้าสุดด้วย Z-index: 10 เพื่อไม่ให้สัญญานพาดทับหน้ากล่อง */
.node-card {
    width: 250px; border-radius: 12px; overflow: hidden; position: relative; z-index: 10; margin-bottom: 24px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.3); backdrop-filter: blur(4px);
}
.node-card:hover { transform: translateY(-4px); z-index: 20; box-shadow: 0 12px 30px rgba(0,0,0,0.6); }

.unit-card { color: #ffffff; border: 1px solid rgba(255,255,255,0.15); }
.unit-card .card-header { background-color: rgba(0, 0, 0, 0.25); padding: 12px 10px; font-size: 14px; font-weight: 600; text-align: center; }
.unit-center-icon-area { height: 120px; display: flex; justify-content: center; align-items: center; background-color: rgba(0, 0, 0, 0.05); }
.unit-icon-orbit { width: 64px; height: 64px; border-radius: 50%; background-color: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); display: flex; justify-content: center; align-items: center; box-shadow: 0 0 15px rgba(255,255,255,0.1); animation: breathing 4s infinite ease-in-out; }
.unit-icon-orbit .material-symbols-outlined { font-size: 32px; color: #ffffff; }
@keyframes breathing { 0%, 100% { transform: scale(1); box-shadow: 0 0 15px rgba(255,255,255,0.1); } 50% { transform: scale(1.06); box-shadow: 0 0 25px rgba(255,255,255,0.25); } }
.unit-mini-dashboard { padding: 15px; background-color: rgba(0, 0, 0, 0.15); display: flex; flex-direction: column; gap: 8px; border-top: 1px solid rgba(255,255,255,0.05); }
.unit-desc-footer { padding: 12px 15px; font-size: 13px; line-height: 1.5; text-align: center; background-color: rgba(0, 0, 0, 0.25); border-top: 1px solid rgba(255,255,255,0.05); color: rgba(255,255,255,0.9); }
.unit-stats { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.stat-row { display: flex; flex-direction: column; gap: 4px; }
.stat-row-header { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; opacity: 0.9; }
.mini-progress-bg { width: 100%; height: 6px; background-color: rgba(0, 0, 0, 0.2); border-radius: 3px; overflow: hidden; }
.mini-progress-fill { height: 100%; background-color: #ffffff; border-radius: 3px; }

.file-node { background-color: var(--card-bg-child); border-top: 3px solid var(--theme-color); }
.file-node .card-header { background-color: transparent; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-color); transition: background-color 0.35s ease, border-color 0.35s ease; }
.header-text-group { display: flex; flex-direction: column; align-items: flex-start; text-align: left; width: 100%; overflow: hidden;}
.file-name-title { font-family: monospace; font-size: 14px; font-weight: 700; color: var(--theme-color); margin-bottom: 4px; transition: color 0.3s; }
.file-name-desc { font-size: 13px; font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; transition: color 0.3s; }

.view-code-btn { background: transparent; border: 1px solid var(--border-color); color: var(--text-muted); width: 28px; height: 28px; border-radius: 6px; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: all 0.2s; flex-shrink: 0; margin-left: 8px;}
.view-code-btn:hover { background: var(--theme-color); color: #fff; border-color: var(--theme-color); }

/* --- 🏷️ พื้นที่และปุ่มสำหรับ Tag ความสัมพันธ์ --- */
.card-tags-area { display: none; flex-wrap: wrap; gap: 6px; padding: 12px 14px; background-color: transparent; border-bottom: 1px solid var(--border-color); }
.node-card.expanded .card-tags-area { display: flex; border-color: rgba(128,128,128,0.1); }
.tag-btn { background: rgba(255, 255, 255, 0.05); border: 1px solid var(--tag-color, #8ba3c7); color: var(--tag-color, var(--text-main)); padding: 4px 10px; border-radius: 12px; font-size: 11px; font-family: monospace; font-weight: bold; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 4px; }
.tag-btn:hover { background: var(--tag-color); color: #ffffff !important; box-shadow: none; } 
.tag-btn.active { background: var(--tag-color); color: #ffffff !important; box-shadow: none; border-color: #fff; } 

.card-accent { height: 40px; display: flex; justify-content: center; align-items: center; position: relative; background-color: rgba(0,0,0,0.15); transition: background-color 0.3s ease; }
.card-accent .material-symbols-outlined { font-size: 24px; color: var(--text-muted); transition: color 0.2s; }
.file-node:hover .card-accent .material-symbols-outlined { color: var(--theme-color); }
.expand-icon { position: absolute; right: 10px; font-size: 20px !important; }
.node-card.expanded .expand-icon { transform: rotate(180deg); }

.card-collapse-area { max-height: 0; overflow: hidden; opacity: 0; transition: max-height 0.4s ease, opacity 0.3s ease; }
.node-card.expanded .card-collapse-area { max-height: 1000px; opacity: 1; }
.card-body { padding: 15px; background: transparent; }
.func-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.func-item { display: flex; align-items: flex-start; gap: 10px; padding: 8px; border-radius: 6px; cursor: pointer; transition: all 0.2s ease; border: 1px solid transparent;}
.func-bullet { width: 6px; height: 6px; border-radius: 50%; background-color: var(--theme-color); flex-shrink: 0; margin-top: 6px; }
.func-text-group { display: flex; flex-direction: column; }
.func-name { font-family: monospace; font-size: 13px; font-weight: bold; color: var(--text-main); transition: color 0.3s ease;}
.func-desc { font-size: 12px; color: var(--text-muted); line-height: 1.4; margin-top: 4px; transition: color 0.3s ease;}

.file-node.expanded .func-item:hover { background-color: rgba(255, 255, 255, 0.05); border-color: rgba(255, 255, 255, 0.1); transform: translateX(5px); }
.file-node.expanded .func-item:hover .func-name { color: var(--theme-color); }

/* --- 🔄 Polarity Inversion (การ์ดขยาย - ต้นทาง) --- */
.file-node.expanded { background-color: var(--inv-bg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3); border-top: 4px solid var(--theme-color); z-index: 20;} 
.file-node.expanded .card-header { background-color: var(--inv-header-bg); border-color: rgba(0,0,0,0.05); }
.file-node.expanded .card-accent { background-color: rgba(0,0,0,0.02); }
.file-node.expanded .file-name-desc { white-space: normal; overflow: visible; width: 100%; color: var(--inv-text-muted); }
.file-node.expanded .func-name { color: var(--inv-text-main); }
.file-node.expanded .func-desc { color: var(--inv-text-muted); }
.file-node.expanded .tag-btn { color: var(--inv-text-muted); border-color: rgba(0,0,0,0.2); }

/* --- ✨ Visual Mirroring Highlight (ไร้แสงฟุ้ง) --- */
.file-node.relation-highlight {
    background-color: var(--inv-bg);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2); /* ไร้แสงฟุ้งสีนีออน */
    border-top: 4px solid var(--highlight-color, #ffffff);
    transform: translateY(-4px) scale(1.02);
    z-index: 20;
}
.file-node.relation-highlight .card-header { background-color: var(--inv-header-bg); border-color: rgba(0,0,0,0.05); }
.file-node.relation-highlight .card-accent { background-color: rgba(0,0,0,0.02); }
.file-node.relation-highlight .file-name-title { color: var(--highlight-color, var(--inv-text-main)); font-size: 15px; }
.file-node.relation-highlight .file-name-desc { color: var(--inv-text-muted); }

/* =========================================
   💻 7. MODALS & POPUPS (THEME LIGHT - UI/UX DESIGN)
   ========================================= */

/* --- 🔗 [UPDATED] Relationship HUD Popup (Top-Center Clean Theme) --- */
.relationship-popup-glass {
    position: fixed;
    top: 85px; /* ล็อกตำแหน่งใต้ Header พอดี */
    left: 50%;
    transform: translate(-50%, -10px);
    width: 440px;
    background: #ffffff !important; /* ย้อมสีขาวนุ่มนวลสะอาดตา */
    border: none !important;
    border-top: 4px solid var(--flow-color, #0081cf) !important;
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(7, 28, 57, 0.25) !important;
    display: none;
    flex-direction: column;
    z-index: 100005 !important; /* ลอยทับ Header ตลอดเวลา */
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.15);
    pointer-events: auto;
}
.relationship-popup-glass.show { display: flex; opacity: 1; transform: translate(-50%, 0); }
.rel-popup-header {
    background: #f8fafc !important; 
    padding: 12px 16px; font-size: 14px; font-weight: 600;
    color: #0f172a !important; 
    border-bottom: 1px solid #e2e8f0;
    display: flex; justify-content: space-between; align-items: center;
}
.rel-close-btn { background: none; border: none; color: #64748b; cursor: pointer; display: flex; align-items: center; padding: 4px; border-radius: 4px; transition: 0.2s; }
.rel-close-btn:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.rel-popup-body { padding: 16px; font-size: 13px; color: #334155 !important; line-height: 1.6; }

/* --- 🔬 [UPDATED] Mini Code Popup (Light Theme) --- */
.mini-code-popup { 
    position: fixed; width: 500px; max-height: 450px; 
    background: #ffffff !important;
    border: 1px solid #cbd5e1;
    border-top: 4px solid var(--theme-color, #0081cf); 
    border-radius: 10px; box-shadow: 0 20px 40px rgba(0,0,0,0.3); z-index: 10000; 
    display: flex; flex-direction: column; overflow: hidden; opacity: 0; 
    transform: scale(0.9); transition: opacity 0.2s, transform 0.2s; pointer-events: none; 
}
.mini-code-popup.show { opacity: 1; transform: scale(1); pointer-events: auto; }
.mini-code-header { 
    background: #f8fafc !important; padding: 12px 15px; 
    font-family: monospace; font-size: 14px; font-weight: bold; 
    color: var(--theme-color, #0081cf) !important;
    border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; 
}
.mini-close-btn { background: none; border: none; color: #64748b; cursor: pointer; display: flex; align-items: center; border-radius: 4px; padding: 4px; transition: 0.2s; }
.mini-close-btn:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.mini-code-body { flex-grow: 1; overflow-y: auto; padding: 15px; background: transparent; }
.mini-code-body::-webkit-scrollbar { width: 8px; }
.mini-code-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.mini-code-content { 
    font-family: 'Consolas', 'Courier New', monospace; font-size: 14px; 
    color: #1e293b !important;
    line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; margin: 0; background: transparent !important; 
}

/* --- 💻 [UPDATED] Full Code Viewer (Universal Light Theme) --- */
.code-modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: none; justify-content: center; align-items: center; z-index: 9999; opacity: 0; transition: opacity 0.3s; }
.code-modal-overlay.show { display: flex; opacity: 1; }
.code-window { width: 90%; max-width: 1200px; height: 85vh; background: var(--code-bg-inv); border-radius: 12px; box-shadow: 0 25px 50px rgba(0,0,0,0.4); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--code-border-inv); transform: scale(0.95); transition: transform 0.3s ease; }
.code-modal-overlay.show .code-window { transform: scale(1); }
.code-header { background: var(--code-header-inv); border-bottom: 1px solid var(--code-border-inv); padding: 15px 25px; display: flex; justify-content: space-between; align-items: center; color: var(--code-text-inv); font-family: monospace; font-weight: bold; font-size: 16px; }
.close-code-btn { background: none; border: none; color: #64748b; cursor: pointer; display: flex; align-items: center; padding: 6px; border-radius: 6px; transition: 0.2s; }
.close-code-btn:hover { background: rgba(239, 68, 68, 0.1); color: #ef4444; }
.code-body-wrapper { flex-grow: 1; display: flex; overflow: hidden; background: var(--code-bg-inv); position: relative; }
.code-line-numbers { padding: 20px 15px; background: var(--code-line-bg-inv); border-right: 1px solid var(--code-border-inv); color: var(--code-text-inv); opacity: 0.5; font-family: 'Consolas', monospace; font-size: 14px; text-align: right; user-select: none; overflow-y: hidden; min-width: 50px; line-height: 1.6; }
.code-content-scroll { flex-grow: 1; overflow-y: auto; overflow-x: hidden; padding: 20px 15px; }
.code-content-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.code-content-scroll::-webkit-scrollbar-track { background: var(--code-bg-inv); }
.code-content-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 5px; }
.code-content { font-family: 'Consolas', 'Courier New', monospace; font-size: 14px; color: var(--code-text-inv); background: transparent; line-height: 1.6; tab-size: 4; white-space: pre-wrap; word-wrap: break-word; word-break: break-all; margin: 0;}
.code-footer { background: #1e293b; color: #ffffff; padding: 10px 25px; font-size: 14px; font-family: monospace; display: flex; align-items: center; gap: 15px; }

/* =========================================
   🖱️ 8. CONTEXT MENU & SYSTEM OVERLAYS
   ========================================= */
.context-menu-glass { position: absolute; width: 220px; background: rgba(11, 15, 25, 0.95); backdrop-filter: blur(20px); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 15px 35px rgba(0,0,0,0.6); border-radius: 10px; display: none; flex-direction: column; z-index: 10000; overflow: visible; animation: fadeInMenu 0.2s ease-out; }
@keyframes fadeInMenu { from { opacity: 0; transform: translateY(-10px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }
.context-header { padding: 12px 15px; background: rgba(0,0,0,0.3); border-bottom: 1px solid rgba(255, 255, 255, 0.05); display: flex; align-items: center; }
.context-menu-list { list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.context-menu-item { padding: 10px 12px; border-radius: 6px; font-size: 14px; color: var(--text-main); font-weight: 500; display: flex; align-items: center; gap: 10px; cursor: pointer; transition: 0.2s; position: relative; }
.context-menu-item .material-symbols-outlined { font-size: 18px; color: var(--text-muted); transition: 0.2s; }
.context-menu-item:hover { background: rgba(255,255,255,0.1); color: #0081cf; }
.context-menu-item:hover .material-symbols-outlined { color: #0081cf; }
.context-divider { height: 1px; background: var(--border-color); margin: 6px 0; }
.danger-item { color: #fb7185 !important; }
.danger-item .material-symbols-outlined { color: #fb7185 !important; }
.danger-item:hover { background: rgba(251, 113, 133, 0.15) !important; color: #f43f5e !important; }

.context-submenu-glass { position: absolute; left: 98%; top: 0; width: 200px; background: rgba(11, 15, 25, 0.98); border: 1px solid rgba(255, 255, 255, 0.15); box-shadow: 0 10px 30px rgba(0,0,0,0.6); border-radius: 8px; list-style: none; padding: 6px; margin: 0; display: none; flex-direction: column; gap: 2px; }
.context-menu-item:hover .context-submenu-glass { display: flex; }
.submenu-item { padding: 8px 12px; border-radius: 4px; font-size: 13px; color: var(--text-main); transition: 0.2s; font-weight: 500; }
.submenu-item:hover { background: #0081cf; color: #ffffff !important; }

.edit-modal-window { width: 440px; background: rgba(11, 15, 25, 0.95); border-radius: 12px; box-shadow: 0 20px 50px rgba(0,0,0,0.8); border: 1px solid var(--border-color); display: flex; flex-direction: column; transform: scale(0.95); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.code-modal-overlay.show .edit-modal-window { transform: scale(1); }
.edit-modal-header { background: var(--header-bg); padding: 15px 20px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.edit-modal-header h3 { margin: 0; font-size: 18px; font-weight: 600; color: var(--text-main); }
.edit-modal-body { padding: 20px; }
.edit-modal-body textarea { width: 100%; box-sizing: border-box; padding: 14px; border-radius: 8px; border: 1px solid var(--border-color); background: rgba(0,0,0,0.2); color: var(--text-main); font-family: var(--font-family); font-size: 14px; line-height: 1.5; resize: none; }
.edit-modal-body textarea:focus { outline: none; border-color: #0081cf; box-shadow: 0 0 0 3px rgba(0, 129, 207, 0.3); }
.edit-modal-footer { padding: 15px 20px; background: rgba(0,0,0,0.3); border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }
.btn-cancel, .btn-save { padding: 8px 16px; border-radius: 6px; cursor: pointer; font-weight: 500; transition: 0.2s; font-size: 14px;}
.btn-cancel { background: transparent; color: var(--text-muted); border: 1px solid var(--border-color); }
.btn-cancel:hover { background: rgba(255,255,255,0.1); color: var(--text-main); }
.btn-save { background: #0081cf; color: #ffffff; border: none; }
.btn-save:hover { background: #006eb5; }

.trash-item { background: rgba(255,255,255,0.05); border: 1px solid rgba(251, 113, 133, 0.3); border-radius: 8px; padding: 12px 15px; display: flex; justify-content: space-between; align-items: center; }
.trash-info { display: flex; flex-direction: column; gap: 4px; text-align: left;}
.trash-filename { font-family: monospace; font-size: 14px; font-weight: bold; color: #fb7185; }
.trash-category { font-size: 13px; color: var(--text-muted); }
.trash-actions { display: flex; gap: 8px; }
.btn-restore, .btn-purge { padding: 6px 12px; border-radius: 6px; cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; transition: 0.2s; }
.btn-restore { background: rgba(0, 143, 122, 0.15); color: #008f7a; border: 1px solid rgba(0, 143, 122, 0.4); }
.btn-restore:hover { background: #008f7a; color: #fff; }
.btn-purge { background: rgba(251, 113, 133, 0.15); color: #fb7185; border: 1px solid rgba(251, 113, 133, 0.4); }
.btn-purge:hover { background: #fb7185; color: #fff; }

.loader { color: var(--text-muted); text-align: center; margin: 100px auto; font-size: 18px; animation: pulse 1.5s infinite; }
@keyframes pulse { 0% { opacity: 0.5; } 50% { opacity: 1; } 100% { opacity: 0.5; } }
.error-state { text-align: center; margin-top: 50px; background: rgba(251, 113, 133, 0.1); border: 1px dashed #fb7185; padding: 40px; border-radius: 12px; display: inline-block; }