/**
 * Types Sidebar Styles
 * 
 * Handles right-side content type filtering sidebar
 * Used on Latest Content, Total Access, and category pages
 * 
 * Version: 1.0.0
 */

/* ============================================
   Content with Sidebar Layout
   ============================================ */

.content-with-sidebar {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap;
    gap: 20px;
    align-items: flex-start;
}

.content-with-sidebar > .documents {
    flex: 1 1 auto;
    min-width: 0;
    max-width: calc(100% - 210px);
    order: 1 !important;
}

/* Types Sidebar (List Mode) */
.content-with-sidebar > .types-sidebar {
    position: sticky;
    top: 100px;
    width: 220px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
    order: 2 !important;
    margin-right: 0;
}

/* Hidden form */
.content-with-sidebar > #latest_content {
    display: none !important;
}

/* ============================================
   Types Sidebar Header
   ============================================ */

.types-header h3,
.types-sidebar-header {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
    padding: 10px;
    border-bottom: 1px solid #e2e8f0;
}

/* Date Range Indicator in Types Sidebar */
.date-range-indicator-types {
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    margin: 8px 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.date-range-indicator-types:hover {
    background: #eff6ff;
    border-left-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
    transform: translateX(2px);
}

.date-range-indicator-types svg {
    flex-shrink: 0;
    color: #3b82f6;
    width: 16px;
    height: 16px;
}

.date-range-indicator-types span {
    font-weight: 600;
    color: #1e40af;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron icon to indicate clickability */
.date-range-indicator-types::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #64748b;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.date-range-indicator-types:hover::after {
    border-top-color: #3b82f6;
    transform: translateY(1px);
}

.types-close {
    display: none; /* Shown only in slide-out mode */
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #64748b;
}

.types-close:hover {
    color: #334155;
}

/* ============================================
   Types List
   ============================================ */

.types-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 0;
}

.type-filter-item,
.type-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: #334155;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.type-filter-item:hover,
.type-item:hover {
    background: #f1f5f9;
}

.type-filter-item.selected,
.type-filter-item.active,
.type-item.active {
    background: #f1f5f9;
    font-weight: 600;
}

.type-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* ============================================
   Color Coding for Types
   (Matches content card border-left colors from style.css)
   ============================================ */

/* All Types */
.type-filter-item.all .type-color { 
    background: linear-gradient(135deg, #94a3b8, #cbd5e1); 
    border: 1px solid #cbd5e1; 
}

/* Confidential Types - matched to pill-inner colors */
.type-filter-item.reports .type-color,
.type-filter-item.alert .type-color { 
    background: #2d7045; /* Green - matches pill-inner-89 */
}
.type-filter-item.monthly-letters .type-color,
.type-filter-item.monthly_letter .type-color { 
    background: #8b50ad; /* Purple - matches pill-inner-168, pill-inner-262 */
}
.type-filter-item.black-papers .type-color,
.type-filter-item.black_paper .type-color { 
    background: #333333; /* Dark gray - matches pill-inner-115 */
}
.type-filter-item.case-studies .type-color,
.type-filter-item.case_study .type-color { 
    background: #0376a9; /* Blue - matches pill-inner-259 */
}
.type-filter-item.qanda .type-color { 
    background: #ff9902; /* Orange - matches pill-inner-220 */
}
.type-filter-item.video .type-color { 
    background: #d0a938; /* Gold - matches pill-inner-4225 */
}
.type-filter-item.fourth-pillar .type-color { 
    background: #c41e3a; /* Dark red - 4th Pillar */
}

/* Total Access Types */
.type-filter-item.podcast .type-color { 
    background: #2d7045; /* Green - matches ta-podcast */
}
.type-filter-item.update .type-color { 
    background: #333333; /* Dark gray - matches ta-updates */
}
.type-filter-item.event .type-color { 
    background: #8b50ad; /* Purple - matches ta-events */
}
.type-filter-item.ta-monthly .type-color { 
    background: #ff9902; /* Orange - matches ta-monthly */
}
.type-filter-item.special-reports .type-color { 
    background: #0376a9; /* Blue - matches ta-reports */
}

/* ============================================
   Slide-out Trigger Button (Grid Mode)
   ============================================ */

.types-slideout-trigger {
    display: none; /* Hidden by default, shown in grid mode */
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.content-with-sidebar > .types-slideout-trigger {
    z-index: 200;
}

.types-slideout-trigger:hover {
    background: linear-gradient(135deg, #334155 0%, #475569 100%);
    transform: translateY(-50%) scale(1.02);
}

.types-slideout-trigger svg {
    opacity: 0.8;
}

.filter-active-dot {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    margin-left: 4px;
}

/* Color the dot based on selected type - Confidential */
.filter-active-dot[data-type="alert"] { background: #2d7045; }
.filter-active-dot[data-type="monthly_letter"] { background: #8b50ad; }
.filter-active-dot[data-type="black_paper"] { background: #333333; }
.filter-active-dot[data-type="case_study"] { background: #0376a9; }
.filter-active-dot[data-type="qanda"] { background: #ff9902; }
.filter-active-dot[data-type="video"] { background: #d0a938; }
.filter-active-dot[data-type="4th_pillar"] { background: #c41e3a; }

/* Color the dot based on selected type - Total Access */
.filter-active-dot[data-type="podcast"] { background: #2d7045; }
.filter-active-dot[data-type="update"] { background: #333333; }
.filter-active-dot[data-type="event_summary"] { background: #8b50ad; }
.filter-active-dot[data-type="report"] { background: #0376a9; }
.filter-active-dot[data-type="ta_monthly"] { background: #ff9902; }
.filter-active-dot[data-type="special_report"] { background: #0376a9; }

/* ============================================
   Slide-out Panel (Mobile/Grid Mode)
   ============================================ */

.types-slideout-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 10000; /* Increased to be above chatbot and back-to-top */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.types-slideout-overlay.open {
    display: block;
    opacity: 1;
}

/* Types slideouts now use products-slideout-panel classes for consistency */
.products-slideout-panel {
    position: fixed;
    top: 135px; /* Aligned with header bottom on mobile */
    right: -300px;
    width: 280px;
    height: calc(100vh - 135px);
    height: calc(100dvh - 135px); /* Modern mobile browsers */
    background: #fff;
    z-index: 10001; /* Increased to be above chatbot and back-to-top */
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Make entire panel scrollable */
    padding-bottom: env(safe-area-inset-bottom, 40px); /* Account for mobile browser toolbars */
    /* Custom scrollbar styling for visibility */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.products-slideout-panel::-webkit-scrollbar {
    width: 6px;
}

.products-slideout-panel::-webkit-scrollbar-track {
    background: transparent;
}

.products-slideout-panel::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 20px;
    border: 3px solid transparent;
}

.products-slideout-panel::-webkit-scrollbar-thumb:hover {
    background-color: #94a3b8;
}

.products-slideout-panel .types-list {
    flex: 1;
    overflow-y: visible; /* Remove scroll from inner element */
    padding: 12px 0;
    gap: 8px;
}

/* Hide floating elements when sidebar is open */
body.types-sidebar-open #sm-chatbot-widget,
body.types-sidebar-open .sm-chatbot-trigger,
body.types-sidebar-open #back-to-top,
body.types-sidebar-open .back-to-top,
body.types-sidebar-open .chatbot-widget {
    display: none !important;
}

.products-slideout-panel.open {
    right: 0;
}

.products-slideout-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    color: #1f2937;
}

.products-slideout-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.calendar-trigger-btn-panel {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.calendar-trigger-btn-panel:hover {
    background: #f1f5f9;
    color: #2c5282;
}

.calendar-trigger-btn-panel:active {
    transform: scale(0.95);
}

.products-slideout-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.products-slideout-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

/* Date Range Indicator in Panel */
.date-range-indicator-panel {
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-left: 3px solid #3b82f6;
    border-radius: 6px;
    margin: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.date-range-indicator-panel:hover {
    background: #eff6ff;
    border-left-color: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

.date-range-indicator-panel svg {
    flex-shrink: 0;
    color: #3b82f6;
    width: 16px;
    height: 16px;
}

.date-range-indicator-panel span {
    font-weight: 600;
    color: #1e40af;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Chevron icon to indicate clickability */
.date-range-indicator-panel::after {
    content: '';
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid #64748b;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.date-range-indicator-panel:hover::after {
    border-top-color: #3b82f6;
    transform: translateY(1px);
}

/* Slide-out panel specific styles for types list */
.products-slideout-panel .types-list {
    gap: 8px;
    padding: 12px 0;
}

.products-slideout-panel .type-filter-item {
    padding: 14px 16px;
    font-size: 14px;
}

/* ============================================
   Grid/List Mode Toggle
   ============================================ */

/* Grid mode: hide sidebar */
.documents-grid ~ .types-sidebar,
.documents.documents-grid + .types-sidebar {
    display: none;
}

/* List mode: show sidebar */
.documents-list ~ .types-sidebar {
    display: block;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1199px) {
    .content-with-sidebar > .documents {
        max-width: calc(100% - 190px);
    }
    
    .content-with-sidebar > .types-sidebar {
        width: 160px;
    }
}

/* ============================================
   Slide-out Trigger Button Hover Effect
   ============================================ */

.types-slideout-trigger {
    display: none;
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #2c5282 0%, #1e3a5f 100%);
    color: #fff;
    border: none;
    padding: 12px 8px;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    z-index: 120;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    box-shadow: -2px 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.types-slideout-trigger:hover {
    padding-right: 12px;
}

.types-slideout-trigger svg {
    flex-shrink: 0;
}

/* Text styling */
.types-text {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.types-slideout-trigger .filter-active-dot {
    position: relative;
    flex-shrink: 0;
}

@media (max-width: 992px) {
    /* Hide sidebar on smaller screens, show slide-out trigger */
    .content-with-sidebar > .types-sidebar {
        display: none !important;
    }
    
    .types-slideout-trigger {
        display: flex !important;
    }
    
    .content-with-sidebar > .documents {
        max-width: 100%;
    }
    .products-slideout-panel {
        top: 135px;
        height: calc(100vh - 135px);
        height: calc(100dvh - 135px);
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px));
    }

}
