/**
 * Teacher Portal – shared sidebar layout and menu styles.
 * Include this on every teacher page. Use js/teacher-sidebar.js to inject the nav.
 * Single source of truth: add a menu item in teacher-sidebar.js and it appears everywhere.
 */

@import url('mobile-first.css');
@import url('portal-chrome-compact.css');
@import url('teacher-portal-layout.css');
@import url('remoed-layers.css?v=app-shell-11');
@import url('portal-header-actions.css');

/* Brand + sidebar tokens — RemoEdPH logo palette (teacher rail is relaxing green) */
:root {
  --remoed-brand-blue: #00aeef;
  --remoed-brand-blue-soft: #5cc8f5;
  --remoed-brand-blue-deep: #008fc4;
  --remoed-brand-green: #47BC3E;
  --remoed-brand-green-soft: #8DF97C;
  --remoed-brand-green-deep: #2E9A28;
  --remoed-brand-yellow: #f0d55c;
  --remoed-sidebar-subtitle: #5c6370;
  --remoed-sidebar-active-start: #2E9A28;
  --remoed-sidebar-active-end: #47BC3E;
  --remoed-sidebar-active-border: #8DF97C;
  --remoed-sidebar-inactive: #2d3748;
  --remoed-sidebar-inactive-hover-bg: rgba(71, 188, 62, 0.12);
  --remoed-sidebar-inactive-hover-text: #2E9A28;
}

/* Sidebar container – fixed, full height (teacher green rail via teacher-portal-layout.css) */
.remoed-sidebar {
    width: 260px;
    min-width: 260px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    box-shadow: 4px 0 20px rgba(15, 23, 42, 0.08);
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow: hidden;
    z-index: 500;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Collapsible mini-sidebar (teacher pages) */
.remoed-sidebar {
    transition:
      width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      min-width 0.28s cubic-bezier(0.4, 0, 0.2, 1),
      max-width 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.remoed-sidebar.sidebar-collapsed {
    width: 72px;
    min-width: 72px;
}

/* Header: logo + Teacher Portal */
.remoed-sidebar .sidebar-header {
    padding: 10px 15px;
    border-bottom: 2px solid #e8f4fd;
}
.remoed-sidebar .sidebar-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 15px;
    box-sizing: border-box;
    width: 100%;
}

.remoed-sidebar .sidebar-collapse-toggle {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 2px solid var(--remoed-brand-green, #47BC3E);
    background: #fff;
    color: var(--remoed-brand-green, #47BC3E);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.remoed-sidebar .sidebar-collapse-toggle:hover,
.remoed-sidebar .sidebar-collapse-toggle:focus-visible {
    background: var(--remoed-brand-green, #47BC3E);
    color: #fff;
    border-color: var(--remoed-brand-green-deep, #2E9A28);
    outline: none;
    transform: scale(1.04);
}
.remoed-sidebar .sidebar-logo-img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
    max-width: 80%;
}
.remoed-sidebar .sidebar-title {
    font-weight: 700;
    color: var(--remoed-brand-blue);
    font-size: 1.1rem;
    line-height: 1.2;
}
.remoed-sidebar .sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--remoed-sidebar-subtitle);
    line-height: 1.25;
}

/* User block: avatar + Hi, [name] */
.remoed-sidebar .sidebar-user {
    padding: 16px;
    border-bottom: 2px solid #e8f4fd;
}
.remoed-sidebar .sidebar-user-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}
.remoed-sidebar #remoed-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--remoed-brand-blue-soft), var(--remoed-brand-blue));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
    flex-shrink: 0;
    overflow: hidden;
    position: relative;
}
.remoed-sidebar #remoed-avatar:hover {
    transform: scale(1.1);
}
.remoed-sidebar #profile-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: none;
}
.remoed-sidebar .remoed-username {
    color: #1a202c;
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

/* Menu list – only the direct child menu scrolls; logout lives in footer */
.remoed-sidebar > .remoed-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1 1 0;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Legacy selector kept for pages that nest menus differently */
.remoed-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.remoed-menu li {
    padding: 12px 24px;
    color: var(--remoed-sidebar-inactive);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 4px solid transparent;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Pending teacher feedback: red dot on Class Schedule + Teaching Fee */
.remoed-menu li[data-nav] {
    position: relative;
}
.remoed-menu li .remoed-pending-dot {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc2626;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
    display: none;
    pointer-events: none;
    flex-shrink: 0;
}
.remoed-menu li.remoed-has-pending .remoed-pending-dot {
    display: block;
}

/* Numeric badge: Class Schedule pending feedback count */
.remoed-menu li .remoed-schedule-count-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95);
    pointer-events: none;
}
.remoed-menu li.remoed-has-pending-count .remoed-schedule-count-badge {
    display: inline-flex;
}
.remoed-sidebar.sidebar-collapsed .remoed-menu li .remoed-schedule-count-badge {
    top: 4px;
    right: 4px;
    min-width: 16px;
    height: 16px;
    font-size: 0.55rem;
}
.remoed-menu li.active .remoed-schedule-count-badge {
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.95);
}
.remoed-sidebar.sidebar-collapsed .remoed-menu li .remoed-pending-dot {
    top: 6px;
    right: 6px;
}
.remoed-menu li.active .remoed-pending-dot {
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.9);
}

.remoed-menu .menu-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.remoed-sidebar.sidebar-collapsed .sidebar-brand,
.remoed-sidebar.sidebar-collapsed .sidebar-subtitle,
.remoed-sidebar.sidebar-collapsed .remoed-username {
    display: none !important;
}

.remoed-sidebar.sidebar-collapsed .sidebar-user {
    padding: 8px !important;
}

.remoed-sidebar.sidebar-collapsed .sidebar-user-inner {
    justify-content: center;
}

.remoed-sidebar.sidebar-collapsed .sidebar-header-inner {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 8px;
}

.remoed-sidebar.sidebar-collapsed .sidebar-logo-img {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    min-height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain !important;
    border-radius: 10px !important;
    padding: 4px;
    box-sizing: border-box;
    margin: 0 auto;
    flex-shrink: 0;
}

.remoed-sidebar.sidebar-collapsed .remoed-menu li {
    justify-content: center;
    padding: 12px 8px;
    gap: 0;
    border-left-width: 0;
}
.remoed-sidebar.sidebar-collapsed .remoed-menu .menu-label,
.remoed-sidebar.sidebar-collapsed .remoed-menu .remoed-menu-label {
    display: none;
}

/* Inactive */
.remoed-menu li:not(.active) {
    color: var(--remoed-sidebar-inactive);
}

/* Active: RemoEd green gradient (teacher portal overrides on green rail) */
.remoed-menu li.active {
    background: linear-gradient(90deg, var(--remoed-sidebar-active-start) 0%, var(--remoed-sidebar-active-end) 100%);
    border-left-color: var(--remoed-sidebar-active-border);
    color: white;
    border-radius: 0 8px 8px 0;
}

.remoed-menu li:not(.active):hover {
    background: var(--remoed-sidebar-inactive-hover-bg);
    color: var(--remoed-sidebar-inactive-hover-text);
    border-radius: 0 8px 8px 0;
}

/* Icons: consistent 2px stroke, inherit color */
.remoed-menu svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
}

.remoed-menu li.active svg {
    stroke: white;
}

/* Logout at bottom – pinned footer (outside scrollable menu; not a .remoed-menu child) */
.remoed-sidebar .sidebar-logout-footer {
    flex: 0 0 auto;
    flex-shrink: 0;
    margin-top: 0;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    background: inherit;
    padding: 6px 8px 12px;
    box-sizing: border-box;
    width: 100%;
}
.remoed-sidebar .sidebar-logout-btn,
.remoed-sidebar #logout-nav.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 16px;
    border: none;
    border-left: 4px solid transparent;
    border-radius: 0 8px 8px 0;
    background: transparent;
    color: #e74c3c;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    text-align: left;
    cursor: pointer;
    overflow: visible;
}
.remoed-sidebar .sidebar-logout-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    stroke-width: 2;
    stroke: #e74c3c;
    fill: none;
}
.remoed-sidebar .sidebar-logout-btn:hover,
.remoed-sidebar .sidebar-logout-btn:focus-visible {
    background: rgba(231, 76, 60, 0.12);
    color: #c0392b;
    outline: none;
}
.remoed-sidebar.sidebar-collapsed .sidebar-logout-btn {
    justify-content: center;
    padding: 12px 0;
    gap: 0;
    border-left-width: 0;
}
.remoed-sidebar.sidebar-collapsed .sidebar-logout-btn .menu-label {
    display: none !important;
}

/* Content area offset when sidebar is present */
.remoed-content {
    margin-left: var(--sidebar-width);
    max-width: calc(100vw - var(--sidebar-width));
    box-sizing: border-box;
}

body.teacher-sidebar-collapsed .remoed-content,
body.student-sidebar-collapsed .remoed-content,
body.admin-sidebar-collapsed .remoed-content,
body.student-portal.student-sidebar-collapsed .remoed-content {
    margin-left: var(--sidebar-collapsed) !important;
    max-width: calc(100vw - var(--sidebar-collapsed)) !important;
}

/* Portal-wide sidebar/drawer/tab-ribbon logic moved to css/global-portal.css */

@media (max-width: 768px) {
    .remoed-menu li {
        padding: 12px 16px;
        font-size: 0.875rem;
    }

    /* Drawer layout: never reserve mini-rail margin on small screens */
    body.teacher-sidebar-collapsed .remoed-content,
    body.student-sidebar-collapsed .remoed-content,
    body.admin-sidebar-collapsed .remoed-content,
    body.student-portal.student-sidebar-collapsed .remoed-content {
        margin-left: 0 !important;
        max-width: 100% !important;
    }
}

/* —— Admin portal only: medium blue nav text (reference UI), not slate grey —— */
.admin-sidebar.remoed-sidebar .sidebar-title {
    color: #2563eb;
}
.admin-sidebar.remoed-sidebar .sidebar-subtitle {
    color: #111827 !important;
    font-weight: 600;
}
.admin-sidebar.remoed-sidebar .remoed-username {
    color: #2563eb;
    font-weight: 600;
}
.admin-sidebar.remoed-sidebar .remoed-menu li:not(.active):not(#logout-nav) {
    color: #2563eb;
}
.admin-sidebar.remoed-sidebar .remoed-menu li:not(.active):not(#logout-nav):hover {
    color: #1d4ed8;
    background: linear-gradient(90deg, rgba(37, 99, 235, 0.12) 0%, rgba(37, 99, 235, 0.06) 100%);
    border-radius: 0 8px 8px 0;
}
.admin-sidebar.remoed-sidebar .remoed-menu li.active {
    background: linear-gradient(90deg, #2563eb 0%, #1d4ed8 100%);
    border-left-color: #1e40af;
    border-radius: 0 8px 8px 0;
    color: white;
}

/* Easier-to-see scrollbars (Firefox) */
html {
    scrollbar-width: auto;
    scrollbar-color: #64748b #e2e8f0;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
    background-color: #64748b;
    border-radius: 8px;
    border: 3px solid #e8edf5;
}

/* Easier-to-see scrollbars (Chrome, Edge, Safari) */
.remoed-content::-webkit-scrollbar,
.tab-content-container::-webkit-scrollbar,
#remo-ai-chatbot .chatbot-messages::-webkit-scrollbar {
    width: 14px;
    height: 14px;
}

.remoed-content::-webkit-scrollbar-thumb,
.tab-content-container::-webkit-scrollbar-thumb,
#remo-ai-chatbot .chatbot-messages::-webkit-scrollbar-thumb {
    background-color: #94a3b8;
    border-radius: 7px;
    border: 3px solid #f1f5f9;
}

.remoed-content::-webkit-scrollbar-track,
.tab-content-container::-webkit-scrollbar-track,
#remo-ai-chatbot .chatbot-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

/* Teaching Fee: AI panel uses column flex; keep footer actions visible */
.page-teacher-service-fee #remo-ai-chatbot.open {
    display: flex !important;
    flex-direction: column;
}

.page-teacher-service-fee #remo-ai-chatbot .chatbot-messages {
    min-height: 0;
}

.page-teacher-service-fee #remo-ai-chatbot .quick-actions,
.page-teacher-service-fee #remo-ai-chatbot .chatbot-input-area {
    flex-shrink: 0;
}

/* —— Portal sidebar chrome (teacher + admin): fixed toggle, desktop collapse —— */
body.remoed-portal-sidebar-mounted {
    --portal-sidebar-w: 280px;
}

.portal-sidebar-toggle {
    position: fixed;
    top: max(12px, env(safe-area-inset-top, 0px));
    left: max(12px, env(safe-area-inset-left, 0px));
    z-index: 300;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 10px;
    border: 2px solid var(--remoed-brand-green, #47BC3E);
    background: #fff;
    color: var(--remoed-brand-green, #47BC3E);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 168, 45, 0.18);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

/* Step 2: keep the toggle out of the sidebar header when sidebar is open */
@media (min-width: 769px) {
    body.remoed-portal-sidebar-mounted:not(.remoed-desktop-sidebar-collapsed) .portal-sidebar-toggle {
        left: calc(var(--portal-sidebar-w, 280px) + 12px);
    }
}

/* Mobile drawer uses the in-sidebar close button; avoid double controls + overlap */
body.remoed-drawer-open .portal-sidebar-toggle {
    display: none;
}

.portal-sidebar-toggle:hover,
.portal-sidebar-toggle:focus-visible {
    background: var(--remoed-brand-green, #47BC3E);
    color: #fff;
    border-color: var(--remoed-brand-green-deep, #2E9A28);
    outline: none;
}

.portal-sidebar-close {
    position: absolute;
    top: 4px;
    right: 4px;
    z-index: 2;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #334155;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.portal-sidebar-close:hover,
.portal-sidebar-close:focus-visible {
    background: #f1f5f9;
    outline: none;
}

@media (min-width: 769px) {
    .portal-sidebar-close {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .portal-sidebar-close {
        display: inline-flex;
    }

    body.remoed-portal-sidebar-mounted .remoed-mobile-topbar .remoed-nav-toggle {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
}

@media (min-width: 769px) {
    body.remoed-portal-sidebar-mounted .remoed-main > [id$="-sidebar-root"] > nav.remoed-sidebar {
        width: var(--portal-sidebar-w);
        min-width: var(--portal-sidebar-w);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
    }

    body.remoed-portal-sidebar-mounted.remoed-desktop-sidebar-collapsed .remoed-main > [id$="-sidebar-root"] > nav.remoed-sidebar {
        transform: translate3d(calc(-1 * var(--portal-sidebar-w)), 0, 0);
        pointer-events: none;
    }

    body.remoed-portal-sidebar-mounted:not(.remoed-desktop-sidebar-collapsed) .remoed-main > .remoed-content {
        margin-left: var(--portal-sidebar-w) !important;
        max-width: calc(100vw - var(--portal-sidebar-w)) !important;
    }

    body.remoed-portal-sidebar-mounted.remoed-desktop-sidebar-collapsed .remoed-main > .remoed-content {
        margin-left: 0 !important;
        max-width: 100% !important;
        padding-left: 56px;
        box-sizing: border-box;
    }

    @media (min-width: 1025px) {
        body.remoed-portal-sidebar-mounted:not(.remoed-desktop-sidebar-collapsed) .remoed-main > .remoed-content.remoed-content--readable,
        body.remoed-portal-sidebar-mounted:not(.remoed-desktop-sidebar-collapsed) .remoed-main > .monitor-wrap {
            margin-left: var(--portal-sidebar-w) !important;
            margin-right: auto !important;
            max-width: min(1200px, calc(100vw - var(--portal-sidebar-w) - 2rem)) !important;
        }

        body.remoed-portal-sidebar-mounted.remoed-desktop-sidebar-collapsed .remoed-main > .remoed-content.remoed-content--readable,
        body.remoed-portal-sidebar-mounted.remoed-desktop-sidebar-collapsed .remoed-main > .monitor-wrap {
            margin-left: auto !important;
            margin-right: auto !important;
            max-width: 1200px !important;
        }
    }
}

/*
 * Admin pages that use body.page-admin-settings (e.g. super-monitor) load style.css rules for a flex
 * .remoed-main. mobile-first.css (≥1025px) centers .remoed-content--readable with margin-left:auto,
 * which lets the fixed sidebar cover the main column until portal-sidebar-chrome runs.
 * This fallback keeps the readable column clear of the sidebar even if JS fails or is cached old.
 */
@media (min-width: 1025px) {
    body.page-admin-settings:not(.remoed-portal-sidebar-mounted) .remoed-main > .remoed-content.remoed-content--readable,
    body.page-admin-settings:not(.remoed-portal-sidebar-mounted) .remoed-main > .remoed-content.monitor-wrap {
        margin-left: 260px !important;
        margin-right: auto !important;
        max-width: min(1200px, calc(100vw - 260px - 2rem)) !important;
    }
}
