/**
 * RdlReports Page Styles
 * 
 * Page-specific styles that extend the base component library.
 * Only add overrides and page-specific layout adjustments here.
 * 
 * Dependencies:
 * - design-tokens.css (CSS custom properties)
 * - rm-components.css (base UI components)
 */

/* ============================================
   PAGE-SPECIFIC LAYOUT
   ============================================ */

/* Input group with icon (for date pickers) */
.rdl-reports .rm-input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.rdl-reports .rm-input-group .rm-input {
    flex: 1;
    padding-right: 40px; /* Space for icon on the right (RTL) */
}

.rdl-reports .rm-input-group .rm-input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--rm-gray-500, #6b7280);
    font-size: 16px;
    pointer-events: auto;
    cursor: pointer;
    transition: color 0.2s ease;
}

.rdl-reports .rm-input-group .rm-input-icon:hover {
    color: var(--rm-primary-base, #00385d);
}

/* Ensure the page selector has the rdl-reports class for backwards compatibility */
.rdl-reports .rm-form-field.rdl-report-type,
.rdl-reports .rm-form-field.group-rdl-report {
    /* Hidden by default, shown via JS when category is selected */
}

/* Legacy class support for show/hide */
.rdl-reports .displaynone {
    display: none !important;
}

/* ============================================
   SELECT2 INTEGRATION
   ============================================ */

/* Apply rm-select2-container styles to Select2 widgets in this page */
.rdl-reports .select2-container {
    width: 100% !important;
}

.rdl-reports .select2-container .select2-selection--single {
    height: 40px !important;
    padding: 0 12px !important;
    border: 0.741px solid #d1d5dc !important;
    border-radius: 8px !important;
    background: #f9fafb !important;
    display: flex !important;
    align-items: center !important;
}

/* When dropdown has value - white background */
.rdl-reports .select2-container--default .select2-selection--single[aria-expanded="false"]:has(.select2-selection__rendered:not(:empty):not([title=""]):not([title="בחר..."])),
.rdl-reports .select2-container.has-value .select2-selection--single {
    background: #fff !important;
}

.rdl-reports .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
    color: var(--rm-input-text) !important;
    font-family: var(--rm-font-primary) !important;
    font-size: var(--rm-text-base) !important;
    padding-right: 0 !important;
    padding-left: 24px !important;
    text-align: right !important;
}

.rdl-reports .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
    left: 8px !important;
    right: auto !important;
}

.rdl-reports .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--rm-input-placeholder) !important;
}

/* ============================================
   CONTROLLER FILTERS HOST
   ============================================ */

#ControllerFiltersHost:not(:empty) {
    margin-bottom: var(--rm-space-6);
}

#ControllerFiltersHost .rm-card {
    /* Ensure dynamically added cards follow the design system */
}

/* ============================================
   EMPTY STATE - Report Selection
   ============================================ */

.rdl-reports .rdl-empty-state {
    padding: var(--rm-space-12) var(--rm-space-6);
}

.rdl-reports .rdl-empty-state-icon {
    width: 80px;
    height: 80px;
    background: var(--rm-gray-100);
    border-radius: var(--rm-radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--rm-space-4);
}

.rdl-reports .rdl-empty-state-icon i {
    font-size: 40px;
    color: var(--rm-gray-400);
}

.rdl-reports .rdl-empty-state-title {
    font-size: var(--rm-text-lg);
    font-weight: var(--rm-font-semibold);
    color: var(--rm-gray-800);
    margin: 0 0 var(--rm-space-2);
    text-align: center;
}

.rdl-reports .rdl-empty-state-text {
    font-size: var(--rm-text-base);
    color: var(--rm-gray-500);
    margin: 0;
    text-align: center;
}

/* ============================================
   ERROR STATES
   ============================================ */

.rdl-reports .rdl-filters-error {
    padding: var(--rm-space-4);
    border-radius: var(--rm-radius-md);
    background: var(--rm-error-light);
    border: 1px solid var(--rm-error);
    color: #b91c1c;
    font-size: var(--rm-text-base);
    font-weight: var(--rm-font-medium);
    margin: var(--rm-space-3) 0;
}

/* ============================================
   CHECKBOX PARAMETER STYLING
   ============================================ */

/* Wrapper: full-width row, aligned to the right (RTL) */
.rdl-reports .rm-checkbox-wrap,
#BaseParametersHost .rm-checkbox-wrap {
    display: flex;
    flex-direction: row-reverse; /* label right, checkbox left (RTL) */
    align-items: center;
    justify-content: flex-end; /* anchor to the right */
    gap: 8px;
    padding: 8px 0;
    width: 100%;
}

/* The actual <input type="checkbox"> */
.rdl-reports .rm-checkbox,
#BaseParametersHost .rm-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--rm-primary-base, #00385d);
}

/* The <label> beside the checkbox */
.rdl-reports .rm-checkbox-label,
#BaseParametersHost .rm-checkbox-label {
    font-family: var(--rm-font-primary);
    font-size: var(--rm-text-base, 14px);
    font-weight: var(--rm-font-medium, 500);
    color: var(--rm-gray-700, #374151);
    cursor: pointer;
    line-height: 1.4;
    text-align: right;
    margin: 0;
    user-select: none;
}

/* ============================================
   BUTTON ICON STYLING
   ============================================ */

.rdl-reports .rm-btn i {
    /* Icon inherits button gap spacing */
}

/* ============================================
   COLLAPSIBLE ADDITIONAL SETTINGS SECTION
   ============================================ */

/* Collapsible card variant */
.rm-card--collapsible {
    /* Same base styles as rm-card */
}

/* Clickable header for collapsible sections */
.rm-card-header--clickable {
    cursor: pointer;
    transition: background var(--rm-transition-fast);
    padding: var(--rm-space-4) var(--rm-space-6);
    min-height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#AdditionalSettingsCard{
    padding: 0 !important;

}

#AdditionalSettingsToggle {
    padding: var(--rm-space-4) var(--rm-space-6);
    margin: 0 !important;
    cursor: pointer;
}

.rm-card-header--clickable:hover {
    background: var(--rm-gray-50);
}

/* Header text in clickable header - simplified */
.rm-card-header--clickable .rm-card-header-text {
    display: flex;
    align-items: center;
    justify-content: space-between; /* title right, badge left in RTL */
    gap: 0; /* no middle gap when spaced to edges */
    flex: 1;
}

.rm-card-header--clickable .rm-card-header-title {
    font-family: var(--rm-font-primary);
    font-size: 14px;
    font-weight: var(--rm-font-medium);
    color: #364153;
    margin: 0;
}

/* Compact filter count badge (pill) shown next to the title */
.filter-badge {
    box-sizing: border-box;
    min-width: 24px; /* narrower */
    height: 24px;
    padding: 0 4px; /* tighter sides */
    border-radius: 9999px; /* full pill */
    background: rgba(35, 135, 203, 0.20); /* secondary 20% */
    color: #2f89d7; /* secondary text */
    line-height: 24px;
}
.filter-badge__count {
    font-family: var(--rm-font-primary);
    font-size: 11px;
    font-weight: var(--rm-font-medium);
}

/* Ensure proper spacing in RTL (badge appears to the left of the title) */
.rm-rtl .rm-card-header--clickable .rm-card-header-text {
    flex-direction: row; /* keep logical order, badge is appended in JS */
}

/* Toggle icon */
.rm-card-header-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #364153;
    transition: transform var(--rm-transition-fast);
}

.rm-card-header-toggle i {
    font-size: 14px;
}

/* Rotate chevron when expanded */
.rm-card--collapsible.is-expanded .rm-card-header-toggle {
    transform: rotate(180deg);
}

/* Collapsible body */
.rm-card-body--collapsed {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--rm-transition-base), padding var(--rm-transition-base);
    padding: 0 var(--rm-space-6);
}

/* Expanded state */
.rm-card--collapsible.is-expanded .rm-card-body--collapsed {
    max-height: 1000px;
    padding: var(--rm-space-6);
    border-top: 1px solid var(--rm-gray-200);
}

/* ============================================
   Filters Dialog Styles
   ============================================ */

/* Dialog Overlay */
.rdl-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 10px;
}

.rdl-dialog-overlay.rm-hidden {
    display: none;
}

/* Dialog Container */
.rdl-dialog {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 900px;
    max-height: calc(100vh - 20px);
    display: flex;
    flex-direction: column;
    animation: rdl-dialog-enter 0.2s ease-out;
}

@keyframes rdl-dialog-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Dialog Header */
.rdl-dialog-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--rm-gray-200, #e5e7eb);
    flex-shrink: 0;
}

.rdl-dialog-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--rm-gray-900, #111827);
}

.rdl-dialog-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--rm-gray-500, #6b7280);
    transition: all 0.15s ease;
}

.rdl-dialog-close:hover {
    background: var(--rm-gray-100, #f3f4f6);
    color: var(--rm-gray-700, #374151);
}

/* Dialog Body - Scrollable */
.rdl-dialog-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 200px;
    max-height: calc(100vh - 200px);
}

/* Dialog Footer */
.rdl-dialog-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--rm-gray-200, #e5e7eb);
    flex-shrink: 0;
}

/* RTL Support for Dialog */
.rm-rtl .rdl-dialog-footer {
    justify-content: flex-start;
}
