/* --- 1. THEME VARIABLES --- */
#dividend-calendar {
    --cal-bg: #FFFFFF;             /* Pure white background */
    --cal-text: #1F2937;           /* Dark slate for high legibility */
    --cal-border: #E5E7EB;         /* Standard light border (Gray 200) */
    --cal-header-bg: #F9FAFB;      /* Light gray tint for headers */
    --cal-group-bg: #F3F4F6;       /* Slightly deeper gray for date bars */
    --cal-past-bg: #F9FAFB;        /* Subtle tint for history */
    --cal-scroll-track: #F3F4F6;
    --cal-scroll-thumb: #D1D5DB;   /* Visible gray thumb */
    --cal-muted: #6B7280;          /* Soft gray for secondary text */
    --ant-blue: #1677ff;           /* Standard Ant Blue */
}

/* --- 2. LAYOUT & SCROLL FIXES --- */
#dividend-calendar {
   width: 90%;

    margin: 0 auto;
    font-size: 13px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !important;
    background-color: var(--cal-bg);
    color: var(--cal-text);
    padding: 2rem;
    transition: background 0.3s ease;
}
#dividend-calendar .flag-img{
    width: 20px;
    height: 13px;
    object-fit: fill;
}
@media (max-width: 991.98px) {
    #dividend-calendar {
        width: 80%;
        padding: 1rem;
    }
}

.tableFixHead {
    /* CRITICAL SCROLL FIXES */
    display: block !important;    /* Ensures height is respected */
    height: 600px !important;     /* Fixed height is required for internal scroll */
    min-height: 600px !important;  /* Match drawer min-height */
    overflow-y: auto !important;  /* Force vertical scrollbar */
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    overscroll-behavior: contain; /* STOPS THE BODY FROM MOVING */
    -webkit-overflow-scrolling: touch; 
    
    background: var(--cal-bg);
    border: 1px solid var(--cal-border);
    border-radius: 4px;
    position: relative;
}

@media (max-width: 768px) {
    .tableFixHead {
        height: auto !important;
        min-height: 400px !important;
        max-height: 60vh !important; /* Restore internal scroll on mobile */
    }
}

/* Ensure the wrapper container allows the 1000px drawer on mobile */
.flex-column.flex-lg-row.position-relative {
    min-height: 600px;
}

.tableFixHead {
    /* CRITICAL SCROLL FIXES */
    display: block !important;    /* Ensures height is respected */
    height: 600px !important;     /* Fixed height for desktop scroll */
    min-height: 600px !important; 
    overflow-y: auto !important;  /* Force vertical scrollbar */
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch; 
    
    background: var(--cal-bg);
    border: 1px solid var(--cal-border);
    border-radius: 4px;
    position: relative;
}

@media (max-width: 768px) {
     #dividend-calendar .justify-content-center-mobile { justify-content: flex-start !important; }
     #dividend-calendar .justify-content-end-mobile { justify-content: flex-end !important; }
     #dividend-calendar .d-md-inline-block-mobile { display: inline-block !important; }
     #dividend-calendar .me-1-mobile { margin-right: 8px !important; }
    
    #dividend-calendar tbody tr:not(.table-light) {
        display: grid;
        grid-template-areas: 
            "date time"
            "country company"
            "dividend dividend";
        grid-template-columns: 1fr 1fr;
        padding: 16px;
        background-color: #111418;
        border: 1px solid var(--cal-border) !important;
        margin-bottom: 12px;
        border-radius: 4px;
        position: relative;
       
    }

    #dividend-calendar tr.highlight-today {
        background-color: #052111 !important;
        border-left: none !important;
    }
}


/* Scrollbar Styling */
#dividend-calendar .tableFixHead::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.tableFixHead::-webkit-scrollbar-track {
    background: var(--cal-scroll-track);
}
.tableFixHead::-webkit-scrollbar-thumb {
    background: var(--cal-scroll-thumb);
    border-radius: 10px;
}

/* --- 3. TABLE STYLING --- */
#dividend-calendar table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
    background-color: transparent !important; /* Allow container bg to show */
}

/* Global cell behavior */
#dividend-calendar table,
#dividend-calendar thead,
#dividend-calendar tbody,
#dividend-calendar tr,
#dividend-calendar td,
#dividend-calendar th {
    background-color: var(--cal-bg) !important;
    color: var(--cal-text) !important;
    border-color: var(--cal-border) !important;
}

/* Sticky Header */
#dividend-calendar thead th {
    position: sticky;
    top: 0;
    z-index: 11; /* Higher than group headers */
    background-color: var(--cal-header-bg) !important;
    color: var(--cal-text);
    font-weight: 500 !important;
    padding: 12px 15px;
    border-bottom: 1px solid var(--cal-border) !important;
}

/* Row Styling */
#dividend-calendar tbody td {
    color: var(--cal-text);
    padding: 8px;
    border-bottom: 1px solid var(--cal-border);
    overflow: visible;
    position: relative;
}

#dividend-calendar tbody th{
    padding: 8px;
}

/* Group Date Header (The gray/dark bars) */
#dividend-calendar .table-light th {
    position: sticky;
    top: 40px; /* Sits right under the main header if scrolling */
    z-index: 10;
    background-color: var(--cal-group-bg) !important;
    color: var(--cal-muted) !important;
    font-weight: 400 !important;
    text-align: center;
}

/* State Fixes */
#dividend-calendar .bg-light, 
#dividend-calendar tr.bg-light td {
    background-color: var(--cal-past-bg) !important;
    opacity: 0.7; /* Optional: makes past items look "expired" */
}

#dividend-calendar .text-muted {
    color: var(--cal-muted) !important;
}

/* Red Timeline Marker */
.red-timeline-border td {
    position: relative;
}
.red-timeline-border td::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background-color: #e03131;
    pointer-events: none;
}

/* --- Mobile Drawer Logic --- */
@media (max-width: 1300px) {
    .ant-sidebar-filters.mobile-drawer .d-lg-none {
        display: block !important;
    }
    .d-none-custom { display: none !important; }
    .d-none-custom-flex { display: none !important; }
    .d-block-custom { display: block !important; }
    .justify-content-custom-end { justify-content: space-between !important; }
}

@media (min-width: 1300px) {
    .d-none-custom { display: inline-flex !important; }
    .d-none-custom-flex { display: flex !important; }
    .d-block-custom { display: none !important; }
    .justify-content-custom-end { justify-content: flex-end !important; }
}

@media (max-width: 1300px) {
    .ant-sidebar-filters.mobile-drawer {
        position: absolute;
        top: 0;
        left: -280px; /* Hidden by default */
        width: 280px;
        height: 100%;
        overflow-y: auto;
        background: var(--ant-bg);
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        border: 1px solid var(--ant-border ) !important;
        margin: 0 !important;
    }

    .ant-sidebar-filters.mobile-drawer.active {
        left: 0; /* Slide in */
    }
    .mobile-filter-toggle.active { background: var(--ant-blue); color: #fff; }

    .mobile-filter-toggle {
        background: var(--ant-bg);
        border: 1px solid var(--ant-border);
        color: var(--ant-text);
        padding: 8px 16px;
        border-radius: 4px;
        margin-bottom: 15px;
        cursor: pointer;
        display: block;
    }

    .ant-sidebar-filters:not(.mobile-drawer) {
        display: none !important;
    }
}

@media (min-width: 1300px) {
  
  
    .mobile-filter-toggle {
        display: none;
    }
}

    .ant-sidebar-filters.mobile-drawer.active {
        left: 0; /* Slide in */
    }

    .mobile-filter-toggle {
        background: var(--ant-bg);
        border: 1px solid var(--ant-border);
        color: var(--ant-text);
        padding: 8px 16px;
        border-radius: 4px;
        margin-bottom: 15px;
        cursor: pointer;
        display: block;
    }


@media (min-width: 992px) {
    .mobile-filter-toggle {
        display: none;
    }
}

.mobile-filter-toggle.active {
    background: var(--ant-blue);
    border-color: var(--ant-blue);
}

.drawer-close {
    background: transparent;
    border: none;
    color: var(--ant-blue);
    font-size: 24px;
    padding: 0 10px;
    cursor: pointer;
}

/* Sidebar Styles */
.ant-sidebar-filters {
    width: 200px;
    border: 1px solid #232629;
    flex-shrink: 0;
}

@media (max-width: 991.98px) {
    .ant-sidebar-filters:not(.mobile-drawer) {
        display: none !important;
    }
}

.ant-sidebar-filters > div {
    font-size: 13px;
}

.ant-sidebar-filters .filter-header {
    font-weight: 700;
}

@media (max-width: 768px) {
    .red-timeline-border td::before {
        display: none;
    }
    tr.red-timeline-border {
        border-top: 2px solid #e03131 !important;
        position: relative;
        margin-top: 10px;
    }
}

.filter-section {
    padding: 12px;
    font-size: 12px;
}

@media (min-width: 992px) {
    .table-responsive.tableFixHead {
        flex: 1 1 auto;
        min-width: 0;
    }
}

.ant-sidebar-filters.mobile-drawer.active {
    left: 0; /* Slide in */
}

@media (min-width: 992px) {
    .ant-sidebar-filters:not(.mobile-drawer) {
        display: none;
    }
}

@media (max-width: 768px) {
    .red-timeline-border td::before {
        display: none;
    }
    tr.red-timeline-border {
        border-top: 2px solid #e03131 !important;
        position: relative;
        margin-top: 10px;
    }
}

.filter-section{
    padding: 12px;
    font-size: 12px;
}

/* Sidebar Styles */
.ant-sidebar-filters {
    width: 200px;
    border: 1px solid #232629;
    flex-shrink: 0;
}

@media (min-width: 992px) {
    .table-responsive.tableFixHead {
        flex: 1 1 auto;
        min-width: 0;
    }
}

.ant-sidebar-filters >div{
    font-size: 13px;
}
.ant-sidebar-filters .filter-header-container{
    position: sticky;
    top: 0px;
    z-index: 10 !important;
    border-bottom: 1px solid #d5cece;
    background: white;
}

.ant-sidebar-filters .filter-header{
    font-weight:  700;
    
}

/* Mobile Fix */
@media (max-width: 991.98px) {
    .ant-sidebar-filters:not(.mobile-drawer) {
        display: none;
    }
}

@media (max-width: 768px) {
    #dividend-calendar { max-width: 100%; padding: 0.5rem; }
    .tableFixHead { height: auto !important; max-height: 600px; }
    .toolbar-container { flex-direction: column; align-items: stretch !important; gap: 10px; }
    .ant-btn-group { flex-wrap: wrap; display: flex; }
    .ant-btn { flex: 1 1 auto; border-bottom: 1px solid var(--ant-border); }
    .ant-btn:last-child { border-bottom: none; }
    
    /* Responsive Table to Cards */
    #dividend-calendar table {
        min-width: 100%;
        table-layout: auto;
    }
    
    #dividend-calendar thead {
        display: none !important; /* Completely remove from flow */
    }
    
    #dividend-calendar .table-light th {
        position: sticky; /* Make sticky on mobile */
        top: 0 !important;
        z-index: 10;
        background-color: var(--cal-group-bg) !important;
    }
    
    #dividend-calendar tbody tr:not(.table-light):not(.status-row) {
        display: grid;
        grid-template-areas: "date time" "country company" "dividend dividend";
        grid-template-columns: 1fr 1fr;
        padding: 12px 16px;
        background-color: #111418;
        border: none !important;
        border-bottom: 1px solid var(--cal-border) !important;
        gap: 4px;
        margin-bottom: 0 !important;
    }
    
    #dividend-calendar tbody tr.status-row {
        display: table-row !important;
    }

    #dividend-calendar tbody tr.status-row td {
        display: table-cell !important;
        text-align: center !important;
        width: 100% !important;
        padding: 100px 0 !important;
    }
    
    #dividend-calendar tbody td {
        display: flex;
        align-items: center;
        border: none !important;
        padding: 0 !important;
        width: auto !important;
        text-align: left !important;
    }

    /* Column 1: Date */
    #dividend-calendar tbody td:nth-child(1) {
        grid-area: date;
        font-weight: 600;
        font-size: 14px;
    }

    /* Column 2: Status/Time */
    #dividend-calendar tbody td:nth-child(2) {
        grid-area: time;
        justify-content: flex-end;
        color: var(--cal-text);
        font-weight: 600;
    }

    /* Column 3: Flag/Country */
    #dividend-calendar tbody td:nth-child(3) {
        grid-area: country;
        justify-content: flex-start;
        color: var(--cal-muted);
    }

    #dividend-calendar tbody td:nth-child(3) img {
        margin-right: 8px;
    }

    /* Column 4: Company */
    #dividend-calendar tbody td:nth-child(4) {
        grid-area: company;
        justify-content: flex-end;
        font-weight: 600;
    }

    .justify-content-center-mobile { justify-content: center; }
    .justify-content-end-mobile { justify-content: flex-end; }
    .d-md-inline-block-mobile { display: inline-block !important; }
    .me-1-mobile { margin-right: 4px !important; }

    /* Column 5: Dividend */
    #dividend-calendar tbody td:nth-child(5) {
        grid-area: dividend;
        justify-content: flex-end;
        font-size: 15px;
        font-weight: 600;
        margin-top: 4px;
    }

    /* Remove previous labels */
    #dividend-calendar tbody td:nth-child(1)::before,
    #dividend-calendar tbody td:nth-child(2)::before,
    #dividend-calendar tbody td:nth-child(4)::before,
    #dividend-calendar tbody td:nth-child(5)::before {
        display: none !important;
    }

    /* Fix highlight border on mobile to span full card */
    #dividend-calendar tr.highlight-today {
        border-left: 3px solid #22c55e !important;
    }

    /* Centered loading/no-results state */
    #dividend-calendar tbody tr:has(td[colspan="5"]) {
        display: table-row !important;
    }
    #dividend-calendar tbody td[colspan="5"] {
        display: table-cell !important;
        width: 100% !important;
        text-align: center !important;
        padding: 100px 0 !important;
    }
}

.flatpickr-calendar {
    z-index: 99999 !important;
    font-family: inherit !important;
    font-size: 14px !important;
    border-radius: 8px !important;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6) !important;
    background: #ffffff !important;
    border: 1px solid var(--ant-border) !important;
   color: var(--ant-text) !important;
}

:root {
    /* Primary Brand Color */
    --ant-blue: #1677ff;
    --ant-blue-bg: rgba(22, 119, 255, 0.1); /* Lighter blue tint for hover states */

    /* Borders & Dividers */
    --ant-border: #d9d9d9;          /* Standard AntD light border */
    
    /* Backgrounds */
    --ant-bg: #ffffff;               /* Pure white container background */
    --ant-item-bg: #fafafa;          /* Very light gray for nested items or hover */

    /* Typography */
    --ant-text: rgba(0, 0, 0, 0.88); /* AntD standard primary text color */
    --ant-text-muted: rgba(0, 0, 0, 0.45); /* For descriptions and "time ago" */
    --ant-text-disabled: rgba(0, 0, 0, 0.25); /* For disabled buttons/inputs */
    
    /* Component Specifics */
    --ant-input-bg: #ffffff;
    --ant-node-selected-bg: #e6f4ff; /* Background for selected rows/tabs */
}
.toolbar-container {
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--ant-text);
    flex-wrap: wrap;
}

@media (max-width: 991.98px) {
    .w-100-mobile { width: 100% !important; }
    .ant-picker { width: 100% !important; }
}

/* --- Buttons --- */
.ant-btn-group {
    display: inline-flex;
    border: 1px solid var(--ant-border);
    border-radius: 6px;
    overflow: hidden;
}
.ant-btn {
    background: transparent;
    border: none;
    border-right: 1px solid var(--ant-border);
    color: var(--ant-text);
    padding: 6px 14px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
}
.ant-btn:last-child { border-right: none; }
.ant-btn.active { background: var(--ant-blue); color: #fff; }

.ant-btn-group-vertical {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--ant-border);
    border-radius: 6px;
    overflow: hidden;
}
.ant-btn-mobile {
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--ant-border);
    color: var(--ant-text);
    padding: 10px 14px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
}
.ant-btn-mobile:last-child { border-bottom: none; }
.ant-btn-mobile.active { background: var(--ant-blue); color: #fff; }

/* --- Picker --- */
.ant-picker {
    display: inline-flex;
    align-items: center;
   background: #fff;
    border: 1px solid var(--cal-border);

    border-radius: 6px;
    padding: 4px 11px;
    position: relative;
    cursor: pointer;
     color: var(--cal-text);
}


.ant-picker-input input {
    background: transparent; border: none; color: var(--ant-text); width: 90px;
    text-align: center; font-size: 14px; outline: none; cursor: pointer;
}
.ant-picker-separator { padding: 0 8px; color: var(--ant-text-disabled); }
.ant-picker-suffix { margin-left: 4px; opacity: 0.5; }

/* Flatpickr Ant Design DARK Customization */
.flatpickr-months .flatpickr-month,
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    color: var(--ant-text) !important;
    fill: var(--ant-text) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months option {
    background: var(--ant-item-bg, #ffffff) !important;
    color: var(--ant-text) !important;
}

.numInputWrapper span.arrowUp:after {
    border-bottom-color: rgba(255, 255, 255, 0.7) !important;
}
.numInputWrapper span.arrowDown:after {
    border-top-color: rgba(255, 255, 255, 0.7) !important;
}

.flatpickr-calendar.arrowTop:before { border-bottom-color: #303030 !important; }
.flatpickr-calendar.arrowTop:after { border-bottom-color: var(--ant-item-bg, #1f1f1f) !important; }
.flatpickr-calendar.arrowBottom:before { border-top-color: #303030 !important; }
.flatpickr-calendar.arrowBottom:after { border-top-color: var(--ant-item-bg, #1f1f1f) !important; }

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    fill: var(--ant-text-muted) !important;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: #1677ff !important;
}
span.flatpickr-weekday {
    color: var(--ant-text-muted) !important;
    font-weight: 600;
}
.flatpickr-day {
    color: var(--ant-text) !important;
    border-radius: 4px !important;
}
.flatpickr-day:hover, .flatpickr-day:focus {
    background: var(--ant-item-bg) !important;
    border-color: var(--ant-border) !important;
}

.flatpickr-day.prevMonthDay, .flatpickr-day.nextMonthDay, .flatpickr-day.flatpickr-disabled {
    color: var(--ant-text-muted) !important;
}
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange,
.flatpickr-day.selected.inRange, .flatpickr-day.startRange.inRange, .flatpickr-day.endRange.inRange,
.flatpickr-day.selected:focus, .flatpickr-day.startRange:focus, .flatpickr-day.endRange:focus,
.flatpickr-day.selected:hover, .flatpickr-day.startRange:hover, .flatpickr-day.endRange:hover,
.flatpickr-day.selected.prevMonthDay, .flatpickr-day.startRange.prevMonthDay, .flatpickr-day.endRange.prevMonthDay,
.flatpickr-day.selected.nextMonthDay, .flatpickr-day.startRange.nextMonthDay, .flatpickr-day.endRange.nextMonthDay {
    background: #1677ff !important;
    border-color: #1677ff !important;
    color:#fff !important;
}
.flatpickr-day.inRange {
    background: rgba(96, 146, 216, 0.2) !important;
    border-color: transparent !important;
    box-shadow: none !important;
    color: var(--ant-text-muted) !important;
}

/* Custom Select Styling */
.custom-select-container {
    position: relative;
    user-select: none;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--ant-bg);
    border: 1px solid var(--ant-border);
    color: var(--ant-text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
    min-width: 200px;
    font-size: 14px;
}

.custom-select-trigger:hover {
    border-color: var(--ant-blue);
}

.custom-select-container.active .custom-select-trigger {
    border-color: var(--ant-blue);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background: var(--ant-bg);
    border: 1px solid var(--ant-border);
    border-radius: 8px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
}

.custom-select-container.active .custom-select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.custom-select-option {
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.2s;
    font-size: 13px;
    color: var(--ant-text);
}

.custom-select-option:hover {
    background: var(--ant-item-bg);
}

.custom-select-option.selected {
    background: #e6f4ff;
    font-weight: 600;
    color: var(--ant-blue);
}

/* Chevron Animation */
.chevron-down {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-right: 1px solid currentColor;
    border-bottom: 1px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.3s;
    margin-left: 8px;
    margin-bottom: 2px;
}

.custom-select-container.active .chevron-down {
    transform: rotate(-135deg) translate(-2px, -2px);
}

/* Scrollbar for options */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}
.custom-select-options::-webkit-scrollbar-thumb {
    background: #d9d9d9;
    border-radius: 10px;
}

@media (max-width: 1300px) {
    .custom-select-trigger {
        min-width: 100%;
    }
}

.currency-item {
    margin-top: 0.5rem;
    margin-bottom:0.5rem;
    color: var(--ant-text);
    cursor: pointer;
    font-size: 12px;
}
.currency-item:hover { color: var(--ant-blue); }

.ant-btn-reset {
    background: transparent;
    border: 1px solid var(--ant-border);
    color: #1677ff;
    padding: 2px 8px;
    border-radius: 2px;
    font-size: 12px;
    cursor: pointer;
}

.ant-checkbox {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    position: relative;
    margin-right: 8px;
}

.ant-checkbox:checked {
    background: var(--ant-blue);
    border-color: var(--ant-blue);
}

.ant-checkbox:checked::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 5px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

#dividend-calendar tr.highlight-today {
    background-color: rgba(34, 197, 94, 0.12) !important;
}
#dividend-calendar tr.highlight-today td {
    background-color: transparent !important;
}
