/* =========================================================================
   Mouza Map Tool – Scoped Styles
   All selectors scoped under #drive-nav-wrapper
   ========================================================================= */

/* --- Glass Panel --- */
#drive-nav-wrapper .glass-panel {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
    border-radius: 1.25rem;
    position: relative;
    overflow: hidden;
}
.dark #drive-nav-wrapper .glass-panel {
    background-color: #1e293b;
    border-color: #334155;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.3);
}

/* --- Search Input --- */
#drive-nav-wrapper .search-input {
    width: 100%;
    padding: 0.6rem 1rem 0.6rem 2.5rem;
    border-radius: 0.75rem;
    border: 1px solid #cbd5e1;
    background-color: #f8fafc;
    color: #0f172a;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    outline: none;
}
.dark #drive-nav-wrapper .search-input {
    background-color: #0f172a;
    border-color: #4b5563;
    color: #f8fafc;
}
#drive-nav-wrapper .search-input:focus {
    border-color: currentColor;
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(129,140,248,0.15);
}
.dark #drive-nav-wrapper .search-input:focus {
    background-color: #1e293b;
}

/* --- Navigation Buttons --- */
#drive-nav-wrapper .nav-button {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: #f1f5f9;
    color: #475569;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    font-size: 0.95rem;
    cursor: pointer;
}
.dark #drive-nav-wrapper .nav-button {
    background-color: #334155;
    color: #cbd5e1;
}
#drive-nav-wrapper .nav-button:hover:not(:disabled) {
    background-color: #e0e7ff;
    color: #4f46e5;
    border-color: #c7d2fe;
    transform: translateY(-1px);
}
.dark #drive-nav-wrapper .nav-button:hover:not(:disabled) {
    background-color: #3730a3;
    color: #818cf8;
    border-color: #4f46e5;
}
#drive-nav-wrapper .nav-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* --- File Item Row --- */
#drive-nav-wrapper .file-item {
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    border: 1px solid transparent;
    position: relative;
}
#drive-nav-wrapper .file-item:hover {
    background-color: #f8fafc;
    border-color: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
}
.dark #drive-nav-wrapper .file-item:hover {
    background-color: rgba(30,41,59,0.7);
    border-color: #4b5563;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

/* --- Action Buttons --- */
#drive-nav-wrapper .action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.85rem;
    text-decoration: none;
}
#drive-nav-wrapper .action-btn:hover {
    transform: scale(1.1);
}

/* 3-dot kebab is mobile-only. The scoped .action-btn `display:flex` above
   out-ranks Tailwind's .sm:hidden, so hide it explicitly on desktop. */
@media (min-width: 640px) {
    #drive-nav-wrapper .action-btn.lt-kebab-btn { display: none; }
}

/* --- Division grid wrapper height transition --- */
#drive-nav-wrapper #division-grid-wrapper {
    transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1), opacity 0.4s ease, margin-bottom 0.4s ease;
    overflow: hidden;
}

/* --- Scrollbar --- */
#drive-nav-wrapper ::-webkit-scrollbar { width: 4px; height: 4px; }
#drive-nav-wrapper ::-webkit-scrollbar-track { background: transparent; }
#drive-nav-wrapper ::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 20px; }
.dark #drive-nav-wrapper ::-webkit-scrollbar-thumb { background-color: #475569; }

/* --- Loading spinner --- */
@keyframes mz-spin { 100% { transform: rotate(360deg); } }
#drive-nav-wrapper .drive-spinner { animation: mz-spin 1s linear infinite; }

/* --- Fade-in for file rows --- */
#drive-nav-wrapper .file-item {
    animation: mz-fadeIn 0.25s ease-out forwards;
}
@keyframes mz-fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Mobile: shrink action buttons to fit 2-col grid --- */
@media (max-width: 639px) {
    #drive-nav-wrapper .action-btn {
        width: 30px;
        height: 30px;
        font-size: 0.75rem;
    }
}

/* =========================================================================
   Mobile: native app-style card list (tighter, edge-to-edge, flat)
   ========================================================================= */
@media (max-width: 639px) {
    /* Pull the page gutters in so the panel reads near full-bleed. */
    #mouza-content { padding-left: 10px; padding-right: 10px; }

    /* Slim the panel's inner gutters so rows get more room. */
    #drive-nav-wrapper #file-manager { padding: 16px 10px; }

    /* Denser list rhythm. */
    #drive-nav-wrapper #file-list { display: flex; flex-direction: column; gap: 8px; }

    /* Flat, modern rows: drop the lifted shadow for a crisp 1px hairline,
       tighten padding, and use a tactile press state instead of hover. */
    #drive-nav-wrapper .file-item {
        padding: 11px 12px;
        border-radius: 14px;
        box-shadow: none;
        border: 1px solid #eef1f5;
    }
    .dark #drive-nav-wrapper .file-item,
    .lt-dark #drive-nav-wrapper .file-item { border-color: #2a3650; }

    /* No hover-lift on touch — it sticks after a tap. Press feedback instead. */
    #drive-nav-wrapper .file-item:hover {
        transform: none;
        box-shadow: none;
        background-color: #ffffff;
        border-color: #eef1f5;
    }
    .dark #drive-nav-wrapper .file-item:hover,
    .lt-dark #drive-nav-wrapper .file-item:hover {
        background-color: rgba(30, 41, 59, 0.8);
        border-color: #2a3650;
    }
    #drive-nav-wrapper .file-item:active {
        transform: scale(0.985);
        background-color: #f5f7fb;
        border-color: #e2e8f0;
    }
    .dark #drive-nav-wrapper .file-item:active,
    .lt-dark #drive-nav-wrapper .file-item:active { background-color: #243047; }

    /* Tighten the file icon gutter. */
    #drive-nav-wrapper .file-item .fa-solid.text-2xl,
    #drive-nav-wrapper .file-item .fa-regular.text-2xl {
        margin-right: 0.65rem;
        font-size: 1.35rem;
    }

    /* Favorites cards (inline-styled in JS) — match the flat row look. */
    #mouza-favorites-cards > div {
        padding: 11px 12px !important;
        border-radius: 14px !important;
        box-shadow: none !important;
        border-color: #eef1f5 !important;
    }
    .dark #mouza-favorites-cards > div,
    .lt-dark #mouza-favorites-cards > div {
        background: rgba(30, 41, 59, 0.8) !important;
        border-color: #2a3650 !important;
    }

    /* Column-label header bar reads quieter on a tight screen. */
    #drive-nav-wrapper #file-manager > .overflow-hidden > .w-full > .flex.px-4.py-3 {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* =========================================================================
   Sticky App Bar + Tabs (replaces the global site header on this page)
   ========================================================================= */
#mouza-appbar {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 900;
    width: 100%;
    background: rgba(255, 255, 255, 0.85);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid #e9edf3;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    font-family: 'Noto Serif Bengali', 'Inter', ui-sans-serif, system-ui, sans-serif;
}
.lt-dark #mouza-appbar,
.dark #mouza-appbar {
    background: rgba(15, 23, 42, 0.85);
    border-bottom-color: #1f2b3e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
/* WP admin bar offset — mirrors .lt-header handling in frame.css. */
.admin-bar #mouza-appbar { top: 32px; }
@media screen and (max-width: 782px) {
    .admin-bar #mouza-appbar { top: 46px; }
}

#mouza-appbar-inner {
    max-width: 64rem;          /* matches #drive-nav-wrapper max-w-5xl */
    margin: 0 auto;
    padding: 8px 16px 10px;
}
@media (min-width: 640px) {
    #mouza-appbar-inner { padding: 10px 24px 12px; }
}

#mouza-appbar-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
}

#mouza-back-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid transparent;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
#mouza-back-btn:hover {
    background: #e0e7ff;
    color: #4f46e5;
    border-color: #c7d2fe;
    transform: translateX(-1px);
}
#mouza-back-btn:active { transform: scale(0.92); }
.lt-dark #mouza-back-btn,
.dark #mouza-back-btn { background: #334155; color: #e2e8f0; }
.lt-dark #mouza-back-btn:hover,
.dark #mouza-back-btn:hover { background: #3730a3; color: #c7d2fe; border-color: #4f46e5; }

#mouza-appbar-title {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 800;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#mouza-appbar-title i { color: #4f46e5; font-size: 1rem; flex-shrink: 0; }
.lt-dark #mouza-appbar-title,
.dark #mouza-appbar-title { color: #f1f5f9; }
.lt-dark #mouza-appbar-title i,
.dark #mouza-appbar-title i { color: #818cf8; }

#mouza-home-link {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 40px;
    padding: 0 14px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #e0e7ff;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s ease;
}
#mouza-home-link i { font-size: 0.95rem; }
#mouza-home-link:hover {
    background: #e0e7ff;
    border-color: #c7d2fe;
    color: #4338ca;
    transform: translateY(-1px);
}
#mouza-home-link:active { transform: scale(0.96); }
.lt-dark #mouza-home-link,
.dark #mouza-home-link {
    background: #312e81;
    color: #c7d2fe;
    border-color: #4f46e5;
}
.lt-dark #mouza-home-link:hover,
.dark #mouza-home-link:hover { background: #3730a3; color: #e0e7ff; }

/* Keep the brand text on mobile, just make the pill more compact */
@media (max-width: 560px) {
    #mouza-home-link { height: 36px; padding: 0 11px; gap: 6px; font-size: 0.8125rem; }
    #mouza-home-link i { font-size: 0.875rem; }
}

#mouza-appbar .lt-dark-btn {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f5f9;
    color: #334155;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}
#mouza-appbar .lt-dark-btn:hover { background: #e2e8f0; }
.lt-dark #mouza-appbar .lt-dark-btn,
.dark #mouza-appbar .lt-dark-btn { background: #334155; color: #fbbf24; }

/* ── Segmented tabs ─────────────────────────────────────────────────────── */
#mouza-tabs {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding: 5px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
}
.lt-dark #mouza-tabs,
.dark #mouza-tabs { background: #0f172a; border-color: #334155; }

.mouza-tab {
    flex: 1 1 0;
    min-width: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: 12px;
    background: transparent;
    color: #64748b;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.22s ease;
    white-space: nowrap;
}
.mouza-tab i { font-size: 0.9rem; }
.mouza-tab:hover:not(.is-active) { color: #334155; background: rgba(148, 163, 184, 0.16); }
.lt-dark .mouza-tab,
.dark .mouza-tab { color: #94a3b8; }
.lt-dark .mouza-tab:hover:not(.is-active),
.dark .mouza-tab:hover:not(.is-active) { color: #e2e8f0; background: rgba(148, 163, 184, 0.12); }

.mouza-tab.is-active {
    background: #ffffff;
    color: #4f46e5;
    border-color: #e2e8f0;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.lt-dark .mouza-tab.is-active,
.dark .mouza-tab.is-active {
    background: #1e293b;
    color: #a5b4fc;
    border-color: #334155;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
/* Favorites tab takes a rose accent when active. */
.mouza-tab[data-tab="favorites"].is-active { color: #e11d48; }
.lt-dark .mouza-tab[data-tab="favorites"].is-active,
.dark .mouza-tab[data-tab="favorites"].is-active { color: #fb7185; }

.mouza-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: #e11d48;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

/* ── Tab panels ─────────────────────────────────────────────────────────── */
.mouza-tab-panel[hidden] { display: none !important; }
.mouza-tab-panel {
    animation: mz-tab-in 0.28s ease-out;
}
@keyframes mz-tab-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
   Full-screen Map Viewer (zoom + pan) — lives outside #drive-nav-wrapper
   ========================================================================= */
#mouza-viewer-modal .drive-spinner { animation: mz-spin 1s linear infinite; }

#mouza-viewer-stage {
    cursor: grab;
    touch-action: none;          /* let JS own pinch/pan gestures */
}
#mouza-viewer-stage:active { cursor: grabbing; }

#mouza-viewer-img {
    transform-origin: center center;
    transition: transform 0.12s ease-out;
    max-width: 96vw;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    will-change: transform;
}

#mouza-viewer-modal .mz-viewer-btn {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}
#mouza-viewer-modal .mz-viewer-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: translateY(-1px);
}
#mouza-viewer-modal .mz-viewer-close:hover {
    background: #ef4444;
    border-color: #ef4444;
}

#mouza-viewer-modal .mz-viewer-zoomlabel {
    min-width: 56px;
    height: 36px;
    padding: 0 10px;
    border-radius: 9999px;
    background: transparent;
    color: #fff;
    border: none;
    cursor: pointer;
    font-weight: 700;
    font-size: 0.8rem;
    transition: background 0.2s ease;
}
#mouza-viewer-modal .mz-viewer-zoomlabel:hover { background: rgba(255, 255, 255, 0.12); }

@media (max-width: 639px) {
    #mouza-viewer-modal .mz-viewer-btn { width: 36px; height: 36px; font-size: 0.85rem; }
    #mouza-viewer-img { max-width: 100vw; max-height: 86vh; }
}

/* =========================================================================
   Mobile action dropdown (3-dot kebab menu) — appended to <body>
   ========================================================================= */
#mouza-action-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: transparent;
}

#mouza-action-menu {
    position: fixed;
    z-index: 99999;
    min-width: 210px;
    max-width: calc(100vw - 16px);
    padding: 6px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.18);
    font-family: 'Noto Serif Bengali', 'Inter', ui-sans-serif, system-ui, sans-serif;
    transform-origin: top right;
    transform: scale(0.95);
    opacity: 0;
    transition: transform 0.14s ease, opacity 0.14s ease;
}
.dark #mouza-action-menu {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 12px 34px rgba(0, 0, 0, 0.45);
}
#mouza-action-menu.lt-am-open {
    transform: scale(1);
    opacity: 1;
}

#mouza-action-menu .lt-am-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: none;
    background: transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #334155;
    text-decoration: none;
    text-align: left;
    transition: background 0.15s ease;
}
.dark #mouza-action-menu .lt-am-item { color: #cbd5e1; }
#mouza-action-menu .lt-am-item:hover,
#mouza-action-menu .lt-am-item:active { background: #f1f5f9; }
.dark #mouza-action-menu .lt-am-item:hover,
.dark #mouza-action-menu .lt-am-item:active { background: #334155; }

#mouza-action-menu .lt-am-item i {
    width: 22px;
    text-align: center;
    font-size: 15px;
    color: #6366f1;
    flex-shrink: 0;
}
#mouza-action-menu .lt-am-item.lt-am-fav i { color: #e11d48; }
