/* ============================================
   SaccoWorks – Layout Compatibility Layer
   Sidebar, Header, Main layout + Menu styles
   (site.css handles Tailwind utilities + components)
   ============================================ */

/* ── CSS Custom Properties for layout shell ── */
:root {
    --kt-sidebar-width: 264px;
    --kt-sidebar-collapsed-width: 78px;
    --kt-header-height: 60px;
    --sw-primary: #3b82f6;
    --sw-primary-dark: #2563eb;
    --sw-bg: #f8fafc;
    --sw-surface: #ffffff;
    --sw-border: #e2e8f0;
    --sw-text: #1e293b;
    --sw-text-muted: #64748b;
    --sw-danger: #dc2626;
    --sw-success: #059669;
    --sw-warning: #d97706;
    --sw-font: 'Inter', system-ui, -apple-system, sans-serif;
}

html.dark {
    --sw-bg: #0f172a;
    --sw-surface: #1e293b;
    --sw-border: #334155;
    --sw-text: #e2e8f0;
    --sw-text-muted: #94a3b8;
    color-scheme: dark;
}

/* ============================================
   LAYOUT: Sidebar + Header + Main
   ============================================ */

.kt-sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--kt-sidebar-width);
    display: flex;
    flex-direction: column;
    z-index: 20;
    background: var(--sw-surface);
    border-right: 1px solid var(--sw-border);
    transition: width 0.3s ease;
    overflow: hidden;
}

/* Sidebar collapse */
body.kt-sidebar-collapse .kt-sidebar { width: var(--kt-sidebar-collapsed-width); }
body.kt-sidebar-collapse .kt-sidebar .kt-sidebar-logo a img { max-width: 30px; }
body.kt-sidebar-collapse .kt-sidebar .kt-menu-title,
body.kt-sidebar-collapse .kt-sidebar .kt-menu-arrow,
body.kt-sidebar-collapse .kt-sidebar .kt-menu-heading,
body.kt-sidebar-collapse .kt-sidebar .kt-menu-bullet,
body.kt-sidebar-collapse .kt-sidebar #sidebarSearch,
body.kt-sidebar-collapse .kt-sidebar .kt-sidebar-header a span { display: none !important; }
body.kt-sidebar-collapse .kt-sidebar .kt-menu-icon { margin: 0 auto; }

/* Mobile sidebar */
@media (max-width: 1023px) {
    .kt-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    body.mobile-sidebar-open .kt-sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.15);
    }
    body.mobile-sidebar-open .sidebar-overlay { display: block; }
}

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 999;
}

/* Sidebar header */
.kt-sidebar-header {
    display: flex; align-items: center;
    padding: 0 16px;
    height: var(--kt-header-height);
    border-bottom: 1px solid var(--sw-border);
    flex-shrink: 0;
}
.kt-sidebar-logo { min-width: 0; }
.kt-sidebar-logo a { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.kt-sidebar-logo a img { height: 28px; width: auto; border-radius: 4px; }

/* Collapse toggle */
#sidebar_toggle {
    position: absolute; right: -14px; top: 50%; transform: translateY(-50%);
    width: 28px; height: 28px; border-radius: 8px;
    border: 1px solid var(--sw-border); background: var(--sw-surface);
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    z-index: 40; font-size: 12px; color: var(--sw-text-muted);
    transition: all 0.15s ease;
}
#sidebar_toggle:hover { background: var(--sw-bg); }
@media (max-width: 1023px) { #sidebar_toggle { display: none; } }

/* Sidebar scrollable content */
.kt-sidebar-content {
    flex: 1; overflow-y: auto;
    padding: 16px 8px 16px 0;
}
.kt-sidebar-content::-webkit-scrollbar { width: 4px; }
.kt-sidebar-content::-webkit-scrollbar-thumb { background: var(--sw-border); border-radius: 4px; }
#sidebar_scrollable { padding: 0 8px 0 16px; width: 100%; }

/* Sidebar search */
#sidebarSearch {
    width: 100%; padding: 8px 12px 8px 34px; font-size: 13px;
    border-radius: 8px; border: 1px solid var(--sw-border);
    background: var(--sw-bg); color: var(--sw-text); outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
#sidebarSearch:focus {
    border-color: var(--sw-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ── Header ── */
header#header, header[id="header"] {
    position: fixed; top: 0; right: 0;
    left: var(--kt-sidebar-width);
    height: var(--kt-header-height);
    display: flex; align-items: center;
    z-index: 10; background: var(--sw-surface);
    border-bottom: 1px solid var(--sw-border);
    padding: 0 20px;
    transition: left 0.3s ease;
}
body.kt-sidebar-collapse header#header,
body.kt-sidebar-collapse header[id="header"] { left: var(--kt-sidebar-collapsed-width); }
@media (max-width: 1023px) {
    header#header, header[id="header"] { left: 0; }
}

/* ── Main content ── */
main {
    margin-left: var(--kt-sidebar-width);
    padding-top: var(--kt-header-height);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}
body.kt-sidebar-collapse main { margin-left: var(--kt-sidebar-collapsed-width); }
@media (max-width: 1023px) { main { margin-left: 0; } }

/* ============================================
   SIDEBAR MENU
   ============================================ */

.kt-menu { display: flex; flex-direction: column; gap: 2px; }

.kt-menu-heading {
    font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--sw-text-muted); padding: 16px 10px 6px;
}

.kt-menu-item { position: relative; }

.kt-menu-link {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px;
    color: var(--sw-text); font-size: 13px;
    cursor: pointer; text-decoration: none; line-height: 1.4;
    transition: background 0.15s ease, color 0.15s ease;
}
.kt-menu-link:hover {
    background: rgba(59, 130, 246, 0.06);
    color: var(--sw-primary);
    text-decoration: none;
}

.kt-menu-icon {
    display: flex; align-items: center; justify-content: center;
    width: 20px; flex-shrink: 0; color: var(--sw-text-muted);
}
.kt-menu-icon i { font-size: 17px; }

.kt-menu-title { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; }

.kt-menu-arrow {
    display: flex; align-items: center;
    color: var(--sw-text-muted); font-size: 10px;
    transition: transform 0.2s ease;
}

/* Accordion */
.kt-menu-accordion {
    display: none; flex-direction: column; gap: 1px;
    padding-left: 10px; margin-left: 20px;
    border-left: 1px solid var(--sw-border);
}
.kt-menu-item-show > .kt-menu-accordion,
.kt-menu-item.show > .kt-menu-accordion { display: flex; }

/* Arrow rotation */
.kt-menu-item-show > .kt-menu-link .kt-menu-arrow,
.kt-menu-item.show > .kt-menu-link .kt-menu-arrow { transform: rotate(90deg); }

/* Arrow plus/minus toggle */
.arrow-plus { display: inline; font-size: 10px; }
.arrow-minus { display: none; font-size: 10px; }
.kt-menu-item-show > .kt-menu-link .arrow-plus { display: none; }
.kt-menu-item-show > .kt-menu-link .arrow-minus { display: inline; }

/* Active module highlight */
.kt-menu-item-here > .kt-menu-link { background: rgba(59, 130, 246, 0.08); }
.kt-menu-item-here > .kt-menu-link .kt-menu-icon,
.kt-menu-item-here > .kt-menu-link .kt-menu-title { color: var(--sw-primary); }

/* Sub-items */
.kt-menu-accordion .kt-menu-link { padding: 6px 10px; font-size: 13px; font-weight: 400; }

/* Bullet dot */
.kt-menu-bullet { display: flex; align-items: center; justify-content: center; width: 20px; flex-shrink: 0; }
.bullet-dot { display: block; width: 5px; height: 5px; border-radius: 50%; background: var(--sw-text-muted); transition: background 0.15s ease; }

/* Active sub-item */
.kt-menu-item-active > .kt-menu-link { color: var(--sw-primary); font-weight: 600; }
.kt-menu-item-active > .kt-menu-link .bullet-dot { background: var(--sw-primary); width: 6px; height: 6px; }
.kt-menu-item-active > .kt-menu-link .kt-menu-title { color: var(--sw-primary); font-weight: 600; }

/* Sub-module dividers */
.hover-submenu-divider { border: none; border-top: 1px solid var(--sw-border); margin: 4px 10px; }
.hover-submenu-title { font-size: 11px; font-weight: 600; color: var(--sw-text-muted); text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px 4px; }

/* ============================================
   HEADER COMPONENTS
   ============================================ */

.kt-btn-icon {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: none; background: transparent;
    color: var(--sw-text-muted); cursor: pointer;
    transition: background 0.15s ease;
}
.kt-btn-icon:hover { background: rgba(0, 0, 0, 0.05); }

/* Dropdowns */
#profileDropdown, #smsTopupPopup {
    position: absolute; top: 100%; right: 0; margin-top: 8px;
    background: var(--sw-surface); border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
    border: 1px solid var(--sw-border); z-index: 50; min-width: 220px;
}

/* Mobile menu button */
button[data-kt-drawer-toggle] {
    width: 36px; height: 36px;
    display: none; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--sw-border);
    background: transparent; color: var(--sw-text-muted); cursor: pointer;
}
@media (max-width: 1023px) { button[data-kt-drawer-toggle] { display: inline-flex; } }

/* Hide mobile text */
@media (max-width: 767px) { .hide-mobile { display: none !important; } }

/* SMS banner */
#smsUrgentBanner {
    display: none; position: fixed;
    top: var(--kt-header-height); left: var(--kt-sidebar-width); right: 0;
    z-index: 9; background: var(--sw-danger); color: #fff;
    text-align: center; font-size: 13px; font-weight: 600; padding: 10px 16px; cursor: pointer;
}
#smsUrgentBanner.show { display: block; }
@media (max-width: 1023px) { #smsUrgentBanner { left: 0; } }

/* Notification modal */
#notificationOverlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.5); backdrop-filter: blur(4px); z-index: 9998;
}
#notificationOverlay.show { display: block; }

#notificationModal {
    position: fixed; top: 0; right: 0;
    width: 460px; max-width: 95vw; height: 100%;
    background: var(--sw-surface);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.15);
    z-index: 9999; transform: translateX(100%);
    transition: transform 0.3s ease;
}
#notificationModal.show { transform: translateX(0); }

.notification-dot {
    position: absolute; top: 4px; right: 4px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--sw-danger); border: 2px solid var(--sw-surface);
}

/* ============================================
   BREADCRUMB
   ============================================ */

.breadcrumb-wrapper { font-size: 13px; }
.breadcrumb-wrapper a, .bc-link {
    color: var(--sw-text-muted); font-size: 13px;
    transition: color 0.15s ease; text-decoration: none;
}
.breadcrumb-wrapper a:hover, .bc-link:hover { color: var(--sw-primary); text-decoration: none; }
.bc-link i { font-size: 13px; }
.bc-sep { color: var(--sw-text-muted); opacity: 0.5; padding: 0 4px; font-size: 9px; }
.bc-sep i { font-size: 9px; }
.bc-module { color: var(--sw-text-muted); font-size: 13px; }
.bc-current { color: var(--sw-text); font-weight: 500; font-size: 13px; }

/* ============================================
   DARK MODE (layout-specific overrides)
   ============================================ */

html.dark .kt-sidebar { background: #1e293b; border-color: #334155; }
html.dark header#header, html.dark header[id="header"] { background: #1e293b; border-color: #334155; }
html.dark #profileDropdown, html.dark #smsTopupPopup { background: #1e293b; border-color: #334155; }
html.dark #notificationModal { background: #1e293b; }
html.dark #sidebarSearch { background: #0f172a; border-color: #334155; color: #e2e8f0; }
html.dark .kt-menu-link:hover { background: rgba(59, 130, 246, 0.1); }

/* ============================================
   PRINT
   ============================================ */

@media print {
    .kt-sidebar, header, #header, #mainSidebar,
    .notification-dot, #smsUrgentBanner,
    #notificationModal, #notificationOverlay,
    button[data-kt-drawer-toggle],
    #sidebar_toggle { display: none !important; }
    main { margin-left: 0 !important; padding-top: 0 !important; }
}
