/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 13px;
    line-height: 1.4;
    color: #1a1a1a;
    background: #f3f4f6;
    overflow: hidden;
}

/* ===== CSS VARIABLES ===== */
:root {
    --teal: #14b8a6;
    --teal-dark: #0f766e;
    --teal-light: #5eead4;
    --orange: #ea580c;
    --green: #10b981;
    --green-dark: #059669;
    --blue: #3b82f6;
    --purple: #8b5cf6;
    --red: #ef4444;
    --yellow: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    /* Layout dimensions */
    --global-nav-height: 48px;
    --sidebar-width: 220px;
    --sidebar-collapsed-width: 60px;
    --context-sidebar-width: 320px;
}

/* ===== APP CONTAINER ===== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ============================================================
   GLOBAL NAVIGATION (Top Bar)
   ============================================================ */
.global-nav {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    height: var(--global-nav-height);
    flex-shrink: 0;
}

.global-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 100%;
}

.global-nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Brand */
.brand {
    font-size: 16px;
    font-weight: 700;
    color: var(--teal);
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    padding-right: 16px;
    border-right: 1px solid var(--gray-200);
}

.brand-icon {
    width: 28px;
    height: 28px;
    background: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 12px;
}

/* Front-End Navigation Icons */
.fe-nav-icons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.fe-nav-btn {
    width: 36px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 10px;
    font-weight: 700;
    transition: all 0.2s;
}

.fe-nav-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.fe-nav-btn.active {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
}

.global-nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    width: 280px;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 12px;
    flex: 1;
    color: var(--gray-700);
}

.search-box input::placeholder {
    color: var(--gray-400);
}

.global-search-icon {
    color: var(--gray-400);
    font-size: 14px;
    /* Unique class name prevents CSS conflicts with dynamically loaded pages */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    line-height: 1;
}

/* Alert Bell */
.alert-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 18px;
    position: relative;
    transition: color 0.2s;
}

.alert-btn:hover {
    color: var(--teal);
}

.alert-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 8px;
    height: 8px;
    background: var(--red);
    border-radius: 50%;
}

/* Menu Notification Badge */
.menu-notification-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    background: var(--red);
    color: white;
    border-radius: 0;
    line-height: 1;
}

/* ============================================================
   MAIN LAYOUT (Three Columns)
   ============================================================ */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ============================================================
   LEFT COLUMN: PORTAL NAVIGATION
   ============================================================ */
.portal-nav {
    width: var(--sidebar-width);
    background: white;
    border-right: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
}

.portal-nav.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.portal-nav-header {
    padding: 0 12px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    height: 49px;
}

.portal-nav-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-700);
    letter-spacing: 0.5px;
}

.portal-nav.collapsed .portal-nav-title {
    display: none;
}

.sidebar-controls {
    display: flex;
    gap: 4px;
}

.sidebar-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    color: var(--gray-500);
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar-btn:hover {
    color: var(--teal);
}

/* Expand button (triangle) - only visible when collapsed */
.expand-btn {
    color: var(--teal);
}

.portal-nav .expand-btn {
    display: none;
}

.portal-nav.collapsed .expand-btn {
    display: flex;
}

/* Pin button - only visible when expanded */
.pin-btn {
    display: flex;
}

.portal-nav.collapsed .pin-btn {
    display: none;
}

.pin-btn.pinned {
    background: var(--teal);
    color: white;
}

.pin-btn.pinned:hover {
    background: var(--teal-dark);
}

/* Center controls when collapsed */
.portal-nav.collapsed .sidebar-controls {
    width: 100%;
    justify-content: center;
}

.portal-nav.collapsed .portal-nav-header {
    justify-content: center;
}

/* Navigation Menu */
.portal-nav-menu {
    flex: 1;
    padding: 0;
    overflow-y: auto;
    position: relative;
}

.portal-section {
    margin-bottom: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Menu Item (Parent) */
.menu-item {
    margin-bottom: 2px;
}

.menu-item-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--gray-700);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.menu-item-header:hover {
    background: var(--gray-100);
}

.menu-item-header.active {
    background: var(--teal);
    color: white;
}

.menu-icon {
    font-size: 16px;
    min-width: 20px;
    text-align: center;
}

.menu-label {
    flex: 1;
}

.portal-nav.collapsed .menu-label,
.portal-nav.collapsed .menu-expand-icon {
    display: none;
}

.menu-expand-icon {
    font-size: 10px;
    color: var(--gray-400);
    transition: transform 0.2s;
}

.menu-item.expanded .menu-expand-icon {
    transform: rotate(90deg);
}

/* Sub-Menu */
.sub-menu {
    display: none;
    padding-left: 32px;
}

.menu-item.expanded .sub-menu {
    display: block;
}

.portal-nav.collapsed .sub-menu {
    display: none !important;
}

.sub-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--gray-600);
    text-decoration: none;
    font-size: 12px;
    border-left: 2px solid transparent;
    transition: all 0.2s;
}

.sub-menu-item:hover {
    color: var(--gray-900);
    background: var(--gray-50);
    border-left-color: var(--gray-300);
}

.sub-menu-item.active {
    color: var(--teal);
    border-left-color: var(--teal);
    background: var(--gray-50);
    font-weight: 500;
}

/* Portal Sections (Multi-Portal Navigation) */
.portal-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--teal);
    background: var(--gray-50);
    transition: background 0.2s;
}

.portal-section-header:hover {
    background: var(--gray-100);
}

.portal-section-header.active {
    background: white;
}

/* Drag Handle */
.drag-handle {
    font-size: 12px;
    color: var(--gray-300);
    cursor: grab;
    padding: 0 4px;
    margin-right: 4px;
    opacity: 0;
    transition: opacity 0.2s, color 0.2s;
    user-select: none;
}

.portal-section-header:hover .drag-handle {
    opacity: 1;
}

.drag-handle:hover {
    color: var(--gray-500);
}

.drag-handle:active {
    cursor: grabbing;
}

/* Bottom Drop Zone */
.portal-drop-zone {
    height: 60px;
    transition: background 0.2s, border 0.2s;
}

.portal-drop-zone.drag-over {
    background: var(--gray-100);
    border-top: 4px solid var(--teal);
}

.portal-nav.collapsed .portal-drop-zone {
    display: none;
}

/* Drag Placeholder - Spotify-style insertion indicator */
.portal-drag-placeholder {
    background: rgba(20, 184, 166, 0.15);
    border: 2px dashed var(--teal);
    overflow: hidden;
    /* Start at 0 height, will be animated via JS */
}

/* Dragging state */
.portal-section.dragging {
    opacity: 0.4;
    position: relative;
    z-index: 1000;
}

/* Touch dragging - element follows finger */
.portal-section.touch-dragging,
.widget-placeholder.touch-dragging {
    position: fixed !important;
    z-index: 2000;
    pointer-events: none;
    opacity: 0.9;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    transform: scale(1.02);
}

.portal-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-700);
    flex: 1;
}

.portal-section-header.active .portal-section-title {
    color: var(--teal);
}

.portal-section-icon {
    font-size: 10px;
    color: var(--gray-400);
    transition: transform 0.2s;
}

.portal-section.expanded .portal-section-icon {
    transform: rotate(90deg);
}

.portal-section-content {
    display: none;
    padding: 4px 0;
}

.portal-section.expanded .portal-section-content {
    display: block;
}

/* Collapsed sidebar: hide section content and titles */
.portal-nav.collapsed .portal-section-content {
    display: none !important;
}

.portal-nav.collapsed .portal-section-title {
    display: none;
}

.portal-nav.collapsed .portal-section-header {
    justify-content: center;
    padding: 8px;
}

.portal-nav.collapsed .portal-section-icon {
    display: none;
}

.portal-nav.collapsed .drag-handle {
    display: none;
}

/* Show abbreviated label when collapsed */
.portal-section-abbrev {
    display: none;
    font-size: 9px;
    font-weight: 700;
    color: var(--gray-600);
}

.portal-nav.collapsed .portal-section-abbrev {
    display: block;
}

.portal-nav.collapsed .portal-section-header.active .portal-section-abbrev {
    color: var(--teal);
}

/* Tooltip for collapsed portal sections */
.portal-section-header {
    position: relative;
}

.portal-nav.collapsed .portal-section-header::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: white;
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-left: 8px;
    z-index: 1000;
}

.portal-nav.collapsed .portal-section-header:hover::after {
    opacity: 1;
}

/* User Footer */
.portal-nav-footer {
    padding: 12px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--teal);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.portal-nav.collapsed .user-info {
    display: none;
}

.user-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-900);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 10px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* User Menu Dropdown */
.user-menu-container {
    position: relative;
}

.portal-nav-footer {
    cursor: pointer;
    transition: background 0.2s;
}

.portal-nav-footer:hover {
    background: var(--gray-100);
}

.user-dropdown {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    display: none;
    z-index: 100;
}

.user-dropdown.show {
    display: block;
}

.user-dropdown-header {
    padding: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.user-dropdown-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}

.user-dropdown-email {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 2px;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.15s;
}

.user-dropdown-item:hover {
    background: var(--gray-100);
}

.user-dropdown-item.logout:hover {
    background: #fef2f2;
    color: var(--red);
}

.user-dropdown-icon {
    font-size: 14px;
    width: 20px;
    text-align: center;
}

/* ============================================================
   CENTER COLUMN: PORTAL CANVAS
   ============================================================ */
.portal-canvas {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* Canvas Toolbar */
.canvas-toolbar {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 49px;
    flex-shrink: 0;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toolbar-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-900);
}

.toolbar-breadcrumb {
    font-size: 11px;
    color: var(--gray-500);
}

.toolbar-breadcrumb span {
    color: var(--gray-400);
    margin: 0 6px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Toolbar Buttons */
.toolbar-btn {
    padding: 6px 12px;
    background: none;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-700);
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--gray-100);
    border-color: var(--gray-300);
}

.toolbar-btn.primary {
    background: var(--teal);
    color: white;
    border-color: var(--teal);
}

.toolbar-btn.primary:hover {
    background: var(--teal-dark);
    border-color: var(--teal-dark);
}

/* View Switcher */
.view-switcher {
    display: flex;
    gap: 0;
    background: var(--gray-100);
    padding: 2px;
}

.view-btn {
    padding: 6px 14px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-600);
    transition: all 0.2s;
}

.view-btn.active {
    background: white;
    color: var(--teal);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* ===== Date/Time Widget ===== */
.toolbar-datetime-widget {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 12px;
    padding-left: 12px;
    border-left: 1px solid var(--gray-200);
    position: relative;
    flex-shrink: 0;
}

.datetime-display {
    font-size: 11px;
    font-weight: 500;
    color: var(--gray-700);
    white-space: nowrap;
    user-select: none;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
}

.datetime-calendar-btn {
    padding: 4px;
    background: none;
    border: 1px solid transparent;
    cursor: pointer;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 3px;
}

.datetime-calendar-btn:hover {
    color: var(--teal);
    border-color: var(--gray-200);
    background: var(--gray-50);
}

.datetime-calendar-btn.active {
    color: var(--teal);
    border-color: var(--teal);
    background: rgba(20, 184, 166, 0.05);
}

/* Calendar Popup */
.datetime-popup {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    width: 280px;
    padding: 14px;
    box-sizing: border-box;
}

.datetime-popup .cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.datetime-popup .cal-month-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-900);
}

.datetime-popup .cal-nav-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-400);
    padding: 2px 8px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.2s;
    border-radius: 3px;
}

.datetime-popup .cal-nav-btn:hover {
    color: var(--teal);
    background: var(--gray-50);
}

.datetime-popup .cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 2px;
    width: 100%;
}

.datetime-popup .cal-weekday {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-400);
    text-align: center;
    padding: 4px 0;
    text-transform: uppercase;
}

.datetime-popup .cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    width: 100%;
}

.datetime-popup .cal-day {
    font-size: 11px;
    color: var(--gray-700);
    text-align: center;
    padding: 5px 0;
    cursor: default;
    border-radius: 3px;
    display: block;
}

.datetime-popup .cal-day.other-month {
    color: var(--gray-300);
}

.datetime-popup .cal-day.today {
    background: var(--teal);
    color: white;
    font-weight: 600;
}

/* Timezone Section */
.datetime-popup .tz-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
}

.datetime-popup .tz-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.datetime-popup .tz-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--gray-600);
    margin-bottom: 4px;
}

.datetime-popup .tz-source {
    font-size: 10px;
    color: var(--gray-400);
    font-style: italic;
}

.datetime-popup .tz-change-link {
    font-size: 10px;
    color: var(--teal);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    font-weight: 500;
}

.datetime-popup .tz-change-link:hover {
    text-decoration: underline;
}

.datetime-popup .tz-picker {
    margin-top: 8px;
}

.datetime-popup .tz-select {
    width: 100%;
    padding: 6px 8px;
    font-size: 11px;
    border: 1px solid var(--gray-200);
    border-radius: 3px;
    color: var(--gray-700);
    background: white;
}

.datetime-popup .tz-save-btn {
    margin-top: 6px;
    padding: 5px 12px;
    background: var(--teal);
    color: white;
    border: none;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s;
}

.datetime-popup .tz-save-btn:hover {
    background: var(--teal-dark);
}

/* Canvas Content Area */
.canvas-content {
    flex: 1;
    overflow: auto;
    padding: 16px;
    background: var(--gray-100);
}

/* Placeholder Content */
.placeholder-content {
    background: white;
    border: 2px dashed var(--gray-300);
    padding: 60px 40px;
    text-align: center;
    color: var(--gray-500);
}

.placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.placeholder-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.placeholder-text {
    font-size: 13px;
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* ============================================================
   RIGHT COLUMN: CONTEXTUAL SIDEBAR
   ============================================================ */
.context-sidebar {
    width: var(--context-sidebar-width);
    background: white;
    border-left: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.3s ease, opacity 0.3s ease;
    flex-shrink: 0;
    position: relative;
}

.context-sidebar.collapsed {
    width: 0;
    border-left: none;
}

/* Expand Tab (visible when collapsed) */
.expand-tab {
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--teal);
    color: white;
    border: none;
    padding: 16px 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 1px;
    box-shadow: -2px 0 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
    display: none;
    z-index: 100;
}

.expand-tab:hover {
    background: var(--teal-dark);
    padding-right: 10px;
}

.context-sidebar.collapsed ~ .expand-tab {
    display: block;
}

/* Context Sidebar Header */
.context-header {
    padding: 0 16px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 49px;
}

.context-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-900);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--gray-500);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.collapse-btn:hover {
    color: var(--gray-700);
}

/* Context Sidebar Content */
.context-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Widget Placeholder — base card style */
.widget-placeholder {
    background: white;
    border: 1px solid var(--gray-200);
    padding: 0;
    text-align: left;
    margin-bottom: 10px;
}

/* Fallback label shown for unrecognised widget keys */
.widget-placeholder-label {
    padding: 20px 14px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    letter-spacing: 0.5px;
    text-align: center;
}

/* ── Widget content structure ──────────────────────────────────────────────── */

.widget-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--gray-100);
}

.widget-icon {
    font-size: 13px;
    color: var(--teal);
    flex-shrink: 0;
}

.widget-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--gray-500);
}

.widget-body {
    padding: 10px 14px 12px;
}

/* Data rows — training-load, athlete-summary */
.widget-data-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 8px;
}

.widget-data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.widget-data-label {
    color: var(--gray-500);
}

.widget-data-value {
    font-weight: 600;
    color: var(--gray-700);
}

/* Note text below data rows or empty states */
.widget-note {
    font-size: 11px;
    color: var(--gray-400);
    font-style: italic;
    margin-top: 6px;
}

/* Upcoming sessions skeleton rows */
.widget-empty-rows {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 10px;
}

.widget-row--empty {
    height: 26px;
    background: var(--gray-100);
}

.widget-empty-msg {
    font-size: 12px;
    color: var(--gray-400);
    margin-bottom: 8px;
}

.widget-action-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--teal);
    text-decoration: none;
}

.widget-action-link:hover {
    color: var(--teal-dark);
    text-decoration: underline;
}

/* Quick notes textarea */
.widget-notes-textarea {
    width: 100%;
    min-height: 80px;
    border: 1px solid var(--gray-200);
    padding: 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--gray-700);
    background: var(--gray-50);
    resize: none;
    overflow: hidden;
    outline: none;
    transition: border-color 0.2s, background 0.2s;
    box-sizing: border-box;
}

.widget-notes-textarea:focus {
    border-color: var(--teal);
    background: white;
}

/* ============================================================
   WIDGET EDIT MODE
   ============================================================ */

/* Edit mode toggle button */
.edit-mode-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-400);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.edit-mode-btn:hover {
    color: var(--gray-600);
}

/* Done button (in edit mode) */
.done-btn {
    background: var(--teal);
    border: none;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    color: white;
    padding: 4px 10px;
    transition: background 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.done-btn:hover {
    background: var(--teal-dark);
}

/* Hide/show based on edit mode */
.context-sidebar:not(.edit-mode) .done-btn,
.context-sidebar:not(.edit-mode) .widget-drag-handle,
.context-sidebar:not(.edit-mode) .widget-remove-btn,
.context-sidebar:not(.edit-mode) .add-widget-btn,
.context-sidebar:not(.edit-mode) .widget-drop-zone {
    display: none;
}

/* Show + Add Widget when the panel has no widgets, even outside edit mode */
.context-sidebar.widgets-empty:not(.edit-mode) .add-widget-btn {
    display: block;
}

.context-sidebar.edit-mode .edit-mode-btn {
    display: none;
}

/* Widget structure in edit mode */
.widget-placeholder {
    position: relative;
    transition: transform 0.2s ease, opacity 0.2s ease, margin 0.2s ease, padding-left 0.2s ease;
}

.context-sidebar.edit-mode .widget-placeholder {
    padding-left: 32px;
}

/* Drag handle for widgets */
.widget-drag-handle {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    cursor: grab;
    color: var(--gray-400);
    font-size: 12px;
    letter-spacing: 2px;
    padding: 4px;
    user-select: none;
    transition: color 0.2s;
}

.widget-drag-handle:hover {
    color: var(--gray-600);
}

.widget-drag-handle:active {
    cursor: grabbing;
}

/* Remove button for widgets */
.widget-remove-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--gray-200);
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}

.widget-remove-btn:hover {
    background: #dc2626;
    color: white;
}

/* Add widget button */
.add-widget-btn {
    background: white;
    border: 2px dashed var(--gray-300);
    padding: 16px;
    text-align: center;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.add-widget-btn:hover {
    border-color: var(--teal);
    color: var(--teal);
    background: rgba(20, 184, 166, 0.05);
}

.add-widget-btn-icon {
    font-size: 20px;
    font-weight: 300;
    display: block;
    margin-bottom: 4px;
}

/* Widget drop zone */
.widget-drop-zone {
    height: 60px;
    transition: background 0.2s, border 0.2s;
}

.widget-drop-zone.drag-over {
    background: var(--gray-100);
    border-top: 4px solid var(--teal);
}

/* Drag placeholder for widgets */
.widget-drag-placeholder {
    background: rgba(20, 184, 166, 0.15);
    border: 2px dashed var(--teal);
    overflow: hidden;
    margin-bottom: 12px;
}

/* Widget dragging state */
.widget-placeholder.dragging {
    opacity: 0.4;
    position: relative;
    z-index: 1000;
}

/* Widget picker dropdown */
.widget-picker {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--gray-200);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.widget-picker-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-700);
    transition: background 0.15s;
}

.widget-picker-item:hover {
    background: var(--gray-50);
}

.widget-picker-item:last-child {
    border-bottom: none;
}

.widget-picker-item.disabled {
    color: var(--gray-400);
    cursor: not-allowed;
}

.widget-picker-item.disabled:hover {
    background: transparent;
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.hidden {
    display: none !important;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   TOOLTIPS (for collapsed sidebar)
   ============================================================ */
.menu-item-header {
    position: relative;
}

.portal-nav.collapsed .menu-item-header::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: white;
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-left: 8px;
    z-index: 1000;
}

.portal-nav.collapsed .menu-item-header:hover::after {
    opacity: 1;
}

/* ============================================================
   MOBILE STYLES
   ============================================================ */

/* Mobile Bottom Bar */
.mobile-bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: white;
    border-top: 1px solid var(--gray-200);
    z-index: 1000;
    justify-content: space-between;
    align-items: center;
    padding: 0 8px;
}

.mobile-nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 48px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    gap: 2px;
    transition: color 0.2s;
}

.mobile-nav-btn:hover,
.mobile-nav-btn.active {
    color: var(--teal);
}

.mobile-nav-btn .icon {
    font-size: 20px;
    line-height: 1;
}

.mobile-nav-btn .label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Hamburger icon lines */
.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 20px;
    height: 20px;
}

.hamburger-icon span {
    display: block;
    width: 18px;
    height: 2px;
    background: currentColor;
    transition: transform 0.2s, opacity 0.2s;
}

/* Context icon (sidebar lines) */
.context-icon {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-end;
    gap: 4px;
    width: 20px;
    height: 20px;
}

.context-icon span {
    display: block;
    height: 2px;
    background: currentColor;
}

.context-icon span:nth-child(1) { width: 18px; }
.context-icon span:nth-child(2) { width: 14px; }
.context-icon span:nth-child(3) { width: 18px; }

/* Mobile Overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    transition: opacity 0.3s;
}

.mobile-overlay.visible {
    opacity: 1;
}

/* Mobile Media Query - includes tablet portrait
   Breakpoint: 1024px
   Rationale: Portal nav (220px) + Context sidebar (320px) = 540px
   At 1024px with both open, canvas = 484px (marginal)
   At 768px with both open, canvas = 228px (unusable)
   Mobile pattern gives full canvas width with slide-in panels */
@media (max-width: 1024px) {
    /* Show mobile elements */
    .mobile-bottom-bar {
        display: flex;
    }
    
    .mobile-overlay {
        display: block;
        pointer-events: none;
    }
    
    .mobile-overlay.visible {
        pointer-events: auto;
    }
    
    /* Adjust main layout for bottom bar */
    .main-layout {
        padding-bottom: 56px;
    }

    /* Content area needs bottom padding too — it scrolls independently */
    .canvas-content {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 16px) !important;
    }

    /* Compact plan grid toggle buttons on mobile */
    .view-btn {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }

    .nav-btn {
        padding: 4px 8px !important;
        font-size: 11px !important;
    }
    
    /* Hide desktop sidebar controls */
    .sidebar-controls {
        display: none !important;
    }
    
    /* Hide expand tab on mobile */
    .expand-tab {
        display: none !important;
    }
    
    /* Hide FE nav on mobile (keep brand) */
    .fe-nav-icons {
        display: none;
    }
    
    /* Simplify global nav */
    .global-nav-inner {
        padding: 0 12px;
    }
    
    .brand {
        padding-right: 0;
        border-right: none;
    }
    
    .search-box,
    .search-box .global-search-icon {
        display: none;
    }
    
    /* Portal Nav - slide in from left */
    .portal-nav {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1002;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .portal-nav.mobile-open {
        transform: translateX(0);
    }
    
    .portal-nav.collapsed {
        width: 280px;
    }
    
    .portal-nav.collapsed .menu-label,
    .portal-nav.collapsed .submenu,
    .portal-nav.collapsed .sidebar-header-title,
    .portal-nav.collapsed .user-name,
    .portal-nav.collapsed .user-role {
        display: block;
        opacity: 1;
    }
    
    .portal-nav.collapsed .sidebar-header {
        justify-content: flex-start;
        padding: 0 16px;
    }
    
    .portal-nav.collapsed .user-info {
        display: flex;
    }
    
    .portal-nav.collapsed .menu-item-header {
        justify-content: flex-start;
        padding: 0 16px;
    }
    
    .portal-nav.collapsed .menu-icon {
        margin-right: 12px;
    }
    
    /* Add close button to portal nav on mobile */
    .mobile-close-btn {
        display: flex;
        position: absolute;
        top: 12px;
        right: 12px;
        width: 32px;
        height: 32px;
        align-items: center;
        justify-content: center;
        background: var(--gray-100);
        border: none;
        cursor: pointer;
        font-size: 18px;
        color: var(--gray-600);
        z-index: 10;
    }
    
    .mobile-close-btn:hover {
        background: var(--gray-200);
        color: var(--gray-800);
    }
    
    /* Context Sidebar - slide in from right */
    .context-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 300px;
        z-index: 1002;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .context-sidebar.mobile-open {
        transform: translateX(0);
    }
    
    .context-sidebar.collapsed {
        width: 300px;
        transform: translateX(100%);
    }
    
    .context-sidebar.collapsed.mobile-open {
        transform: translateX(0);
    }
    
    /* Canvas takes full width */
    .portal-canvas {
        margin-left: 0;
        margin-right: 0;
    }
    
    /* Canvas toolbar adjustments */
    .canvas-toolbar {
        flex-wrap: wrap;
        gap: 4px;
        height: auto;
        min-height: 49px;
        padding: 8px 16px;
    }
    
    .canvas-toolbar-left {
        flex: 1;
        min-width: 100%;
    }
    
    .canvas-toolbar-right {
        flex: 1;
        min-width: 100%;
        justify-content: flex-start;
    }
    
    /* Breadcrumb wrapping */
    .breadcrumb {
        flex-wrap: wrap;
    }
    
    /* Always show drag handles on mobile */
    .drag-handle {
        opacity: 1;
    }

    /* Date/Time Widget - compact on small screens */
    .toolbar-datetime-widget {
        border-left: none;
        margin-left: 8px;
        padding-left: 0;
    }

    .datetime-display {
        font-size: 10px;
    }

    .canvas-content {
        padding: 8px;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
    }
}

@media (max-width: 480px) {
    .canvas-content {
        padding: 4px;
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 4px);
    }
}

/* Hide mobile close button on desktop */
@media (min-width: 1025px) {
    .mobile-close-btn {
        display: none;
    }
}

/* ============================================================
   NAV SECTION LABELS, DIVIDERS & SUB-MENU GROUPS
   ============================================================ */
.nav-section-label {
    padding: 8px 12px 2px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gray-300);
}

.nav-section-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 4px 0;
}

.sub-menu-group-label {
    padding: 8px 12px 2px 12px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--gray-300);
}

/* Muted nav items (roadmap placeholders) */
.sub-menu-item.muted {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.menu-item-header.muted {
    opacity: 0.45;
    cursor: default;
    pointer-events: none;
}

/* Phosphor Icon styles in nav menu headers */
.menu-icon.ph {
    font-size: 16px;
    min-width: 20px;
    text-align: center;
    color: var(--gray-400);
    flex-shrink: 0;
}

.menu-item-header.active .menu-icon.ph {
    color: white;
}

/* Phosphor Icon styles in sub-menu items */
.sub-menu-item i.ph {
    font-size: 13px;
    min-width: 14px;
    text-align: center;
    color: var(--gray-300);
    flex-shrink: 0;
}

.sub-menu-item.active i.ph {
    color: var(--teal);
}

/* ── Admin-disabled context panel ─────────────────────────────────────────── */
/* Applied by _reloadContextWidgets() when slideractive=false for this page. */
/* Separate from the user-controlled .collapsed class so they do not conflict. */
.panel-admin-off {
    display: none !important;
}
