/* Button styling (from your global css structure) */
.mfg-load-glyphs-btn {
    display: inline-block;
    margin-top: 10px;
    padding: 10px 15px;
    background-color: var(--theme-palette-color-16);
    color: var(--theme-palette-color-6);
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.3s;
}
.mfg-load-glyphs-btn:hover { background-color:var(--theme-palette-color-13); }

/* 1. MODAL OVERLAY (UNCHANGED) */
#mfg-modal {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85); /* Deep slate semi-transparent */
    display: flex;
    align-items: center; /* Center vertically */
    justify-content: center; /* Center horizontally */
    padding: 20px;
}

/* 2. MODAL BOX (UNCHANGED) */
.mfg-modal-content {
    background-color: var(--theme-palette-color-8);
    width: 95%;
    max-width: 1100px;
    height: 90vh; /* FIXED: Locks the height immediately so it doesn't jump */
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    padding: 40px;
}

/* 3. CLOSE BUTTON (UNCHANGED) */
.mfg-close {
    position: absolute;
    right: 25px;
    top: 20px;
    color: var(--theme-palette-color-10);
    font-size: 35px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.2s;
}
.mfg-close:hover { color: #0f172a; }

/* 4. LOADING STATE (UNCHANGED) */
#mfg-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%; /* FIXED: Takes up the full height of the 90vh box to stay centered */
    font-size: 18px;
    color: var(--theme-palette-color-10);
    font-weight: 500;
}

.mfg-spinner {
    border: 3px solid #f1f5f9;
    border-top: 3px solid var(--theme-palette-color-1); /* Modern Blue */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: mfg-spin 0.8s linear infinite;
    margin-bottom: 20px;
}
@keyframes mfg-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* TABS - Clean Management Style (Horizontal Scroll) */
.mfg-tabs {
    list-style: none;
    padding: 0 0 5px 0;
    margin: 0 0 30px 0;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    border-bottom: 1px solid var(--theme-palette-color-5);
}

.mfg-tabs::-webkit-scrollbar { height: 10px; }
.mfg-tabs::-webkit-scrollbar-track { background: transparent; }
.mfg-tabs::-webkit-scrollbar-thumb { background-color: var(--theme-palette-color-5); border-radius: 4px; }

.mfg-tab-link {
    padding: 8px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--theme-palette-color-10);
    background: var(--theme-palette-color-9);
    border: 1px solid var(--theme-palette-color-5);
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.mfg-tab-link:hover {
    background: var(--theme-palette-color-11);
    color: var(--theme-palette-color-10);
}

.mfg-tab-link.active {
    background: var(--theme-palette-color-8);
    color: var(--theme-palette-color-1);
    border-top: 1px solid var(--theme-palette-color-1);
    border-left: 1px solid var(--theme-palette-color-5);
    border-right: 1px solid var(--theme-palette-color-5);
    box-shadow: inset 0 3px 0 0 var(--theme-palette-color-1);
    margin-top: 0;
    position: relative;
    z-index: 2;
}

/* 5. OVERALL STRUCTURE AND MAIN TITLE */
.mfg-font-file-view {
    /* font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; */
}

.mfg-file-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--theme-palette-color-10);
    margin-bottom: 30px;
    border-bottom: 1px solid var(--theme-palette-color-5);
    padding-bottom: 15px;
}

/* 6. SOPHISTICATED CATEGORY AREA */
.mfg-glyphs-category {
    margin-bottom: 40px;
}

/* Structured category header (matched to your original h3 style) */
.mfg-glyphs-category-header {
    font-size: 20px;
    font-weight: 700;
    color: var(--theme-palette-color-13);
    margin-bottom: 20px;
    border-left: 4px solid var(--theme-palette-color-1);
    padding-left: 15px;
}

/* Structured category glyph grid (Photoshop style layout) */
.mfg-glyphs-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); /* Clean uniform boxes */
    gap: 15px;
    padding: 0;
}

/* 7. INDIVIDUAL GLYPH BOX (The stunning detail) */
.mfg-glyph-box {
    background-color: var(--theme-palette-color-9);
    border: 1px solid var(--theme-palette-color-5);
    border-radius: 6px;
    position: relative;
    cursor: default;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 / 1; /* Forces the box to be a perfect square */
}

.mfg-glyph-box:hover {
    border-color: var(--theme-palette-color-1);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Main glyph display (The Stunning Part) */
.mfg-glyph-display {
    font-size: 36px;
    font-weight: 400;
    color: var(--theme-palette-color-10);
    text-align: center;
    margin: 0;
    padding: 0;
    line-height: 1;
}
/* Hover/Detail information at the bottom of the box (Photoshop style) */
.mfg-glyph-hover-info {
    font-size: 11px;
    background-color: var(--theme-palette-color-8); /* Match to your global css color-8 */
    color: var(--theme-palette-color-10);
    text-align: center;
    padding: 8px 5px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-top: 1px solid var(--theme-palette-color-5);
    opacity: 0.8; /* Dim information when not hovering */
    transition: opacity 0.2s;
}

.mfg-glyph-box:hover .mfg-glyph-hover-info {
    opacity: 1; /* Show full information on hover */
}

.mfg-glyph-hex {
    font-weight: bold;
    color: var(--theme-palette-color-13);
}

.mfg-glyph-name {
    font-style: italic;
    opacity: 0.8;
}

/* 8. BIG GLYPH TOOLTIP (Smooth Fade & Slide) */
#mfg-big-tooltip {
    position: absolute;
	top: -9999px;  /* THE FIX: Stores the invisible box way off-screen */
    left: -9999px; /* THE FIX: Prevents it from creating horizontal scrollbars */
    z-index: 9999999;
    /* Animation base setup instead of display: none */
    display: flex;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px); /* Starts slightly lower */
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    background-color: var(--theme-palette-color-8);
    border: 2px solid var(--theme-palette-color-1);
    color: var(--theme-palette-color-10);
    border-radius: 12px;
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.3);
    padding: 20px;
    font-size: 80px;
    line-height: 1;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    min-height: 100px;
    text-align: center;
}

/* The active state that triggers the animation */
#mfg-big-tooltip.mfg-show-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0); /* Slides up into its final position */
}

/* The outer border of the down arrow */
#mfg-big-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -12px;
    border-width: 12px;
    border-style: solid;
    border-color: var(--theme-palette-color-1) transparent transparent transparent;
}

/* The inner background of the down arrow */
#mfg-big-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -9px;
    border-width: 9px;
    border-style: solid;
    border-color: var(--theme-palette-color-8) transparent transparent transparent;
}
/* Responsive adjust for small screens (UNCHANGED) */
@media screen and (max-width: 1200px) {
    .mfg-modal-content { width: 98%; padding: 25px; }
    .mfg-glyphs-category-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); gap: 10px; }
    .mfg-glyph-display { font-size: 30px; }
}
