/* ==========================================================================
   Customizable Reports Workspace - Modern SaaS BI Styling
   ========================================================================== */

/* Outer Page Wrapper */
.report-workspace-container {
    padding: 1.25rem;
    /*background-color: #f1f5f9;*/
    min-height: calc(100vh - 60px);
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1e293b;
}

/* Main Workspace Card */
.report-workspace-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 85vh;
}

/* ==========================================================================
   Top Header Toolbar
   ========================================================================== */
.report-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    flex-wrap: wrap;
    gap: 1rem;
}

.topbar-left {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.workspace-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

/* Date Range Pill */
.report-date-pill {
    display: inline-flex;
    align-items: center;
    background: #f0f4f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem 0.85rem;
    gap: 0.65rem;
}

.report-date-label {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #2563eb;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    white-space: nowrap;
}

.report-date-input-wrap {
    display: inline-flex;
    align-items: center;
}

.report-date-input {
    border: none;
    background: transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1e293b;
    outline: none;
    padding: 0;
    width: 115px;
    font-family: inherit;
    cursor: pointer;
}

.report-date-input::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s;
    font-size: 0.85rem;
}

.report-date-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.report-date-sep {
    color: #94a3b8;
    font-size: 0.8125rem;
    font-weight: 400;
}

/* Presets Dropdown Button */
.btn-presets {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.btn-presets:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

/* Reset Button */
.btn-reset {
    background: transparent;
    border: none;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #475569;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s ease-in-out;
}

.btn-reset:hover {
    color: #0f172a;
    background: #f8fafc;
}

/* Export Dropdown Button in Topbar */
.btn-export {
    display: inline-flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.45rem 0.95rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
    cursor: pointer;
}

.btn-export:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.btn-export:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Quick Export in Subbar */
.btn-subbar-action {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 0.2rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s ease-in-out;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.btn-subbar-action:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-subbar-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Generate Report Button */
.btn-generate {
    background: #1d4ed8;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 1px 2px rgba(29, 78, 216, 0.2);
}

.btn-generate:hover:not(:disabled) {
    background: #1e40af;
    box-shadow: 0 2px 4px rgba(29, 78, 216, 0.3);
}

.btn-generate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ==========================================================================
   Main Body: Split Canvas & Field Builder
   ========================================================================== */
.report-body {
    display: flex;
    flex: 1 1 auto;
    min-height: 0;
}

/* Left Canvas Area */
.report-canvas {
    flex: 1 1 auto;
    min-width: 0;
    padding: 1.5rem 2rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Right Field Builder Sidebar */
.field-builder-sidebar {
    width: 320px;
    flex: 0 0 320px;
    border-left: 1px solid #e2e8f0;
    padding: 1.25rem 1.5rem;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: calc(100vh - 120px);
}

/* ==========================================================================
   Report Canvas Header & Sub-bar
   ========================================================================== */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.report-main-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 0.25rem 0;
    letter-spacing: -0.3px;
    line-height: 1.2;
    cursor: default;
}

.report-title-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.report-badge {
    display: inline-flex;
    align-items: center;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 9999px;
    letter-spacing: 0.3px;
    line-height: 1;
    vertical-align: middle;
}

.report-badge.badge-preset {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.report-badge.badge-custom {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

.btn-edit-title {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.8125rem;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s, background-color 0.15s;
}

.btn-edit-title:hover {
    color: #1d4ed8;
    background-color: #f1f5f9;
}

.btn-auto-title {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.7125rem;
    font-weight: 500;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.15s ease-in-out;
}

.btn-auto-title:hover {
    background: #f1f5f9;
    color: #1d4ed8;
    border-color: #cbd5e1;
}

.report-title-edit-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.25rem;
}

.report-title-input {
    font-size: 1.15rem;
    font-weight: 700;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    padding: 0.2rem 0.55rem;
    outline: none;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    min-width: 320px;
    letter-spacing: -0.2px;
}

.btn-title-save {
    background: #10b981;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 0.25rem 0.55rem;
    font-size: 0.8125rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.btn-title-save:hover {
    background: #059669;
}

.btn-title-cancel {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.25rem 0.55rem;
    font-size: 0.8125rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.btn-title-cancel:hover {
    background: #e2e8f0;
    color: #334155;
}

.btn-title-reset {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.25rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
}

.btn-title-reset:hover {
    background: #dbeafe;
}

.report-subtitle {
    font-size: 0.8125rem;
    color: #64748b;
    font-weight: 400;
}

.report-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

.meta-dot {
    color: #3b82f6;
    font-size: 0.95rem;
    line-height: 1;
}

/* Sub-toolbar */
.report-subbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
    border-top: 1px solid #f1f5f9;
    margin-bottom: 0.5rem;
}

.subbar-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.subbar-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 500;
}

.totals-checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.totals-check {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid #cbd5e1;
    cursor: pointer;
    margin: 0;
}

.totals-check:checked {
    background-color: #2563eb;
    border-color: #2563eb;
}

.btn-toggle-fields {
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.8125rem;
    font-weight: 500;
    color: #2563eb;
    cursor: pointer;
    text-decoration: none;
    transition: color 0.15s;
}

.btn-toggle-fields:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* ==========================================================================
   Pivot Table Component
   ========================================================================== */
.report-grid-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.report-table-scroll-container {
    width: 100%;
    overflow-x: auto;
}

.report-loading-container,
.report-empty-container {
    padding: 4rem 2rem;
    text-align: center;
}

.report-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.8125rem;
}

/* Corner Header Spec (Columns / Rows labels) */
.table-corner-header {
    text-align: left;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    vertical-align: middle;
    width: 240px;
    min-width: 200px;
}

.corner-spec-line {
    font-size: 0.75rem;
    line-height: 1.5;
    white-space: normal;
}

.spec-label {
    color: #64748b;
    font-weight: 600;
    margin-right: 0.35rem;
}

.spec-val {
    color: #1e293b;
    font-weight: 500;
}

/* Level 1 Group Header (e.g. 2026 / Q2) */
.table-col-group-header {
    text-align: center;
    font-weight: 700;
    color: #0f172a;
    font-size: 0.8125rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    white-space: nowrap;
}

/* Level 2 Metric Header (e.g. Total Orders (Count)) */
.table-metric-subhead {
    text-align: center;
    font-weight: 500;
    color: #64748b;
    font-size: 0.75rem;
    padding: 0.6rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    white-space: nowrap;
}

/* Row Identifier Cell (e.g. IA, IL, ME) */
.table-row-name-cell {
    text-align: left;
    font-weight: 600;
    color: #0f172a;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f1f5f9;
    background: #ffffff;
    white-space: nowrap;
}

/* Matrix Data Cell */
.table-metric-val-cell {
    text-align: right;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    border-right: 1px solid #f1f5f9;
    color: #334155;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* Hover State */
.report-table tbody tr.report-data-row:hover td,
.report-table tbody tr.report-data-row:hover th {
    background-color: #f8fafc;
}

/* Total Columns & Rows */
.table-total-col,
.table-total-row {
    background-color: #f8fafc;
    font-weight: 600;
    color: #1e40af;
}

.table-corner-total {
    background-color: #eff6ff !important;
    font-weight: 700;
    color: #1d4ed8;
}

/* ==========================================================================
   Field Builder Panel (Right)
   ========================================================================== */
.field-builder-panel {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.builder-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin: 0;
}

.builder-count {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 400;
}

/* Search Box */
.builder-search-box {
    position: relative;
    width: 100%;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.8125rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.45rem 0.75rem 0.45rem 2.2rem;
    font-size: 0.8125rem;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s, background-color 0.15s;
}

.search-input:focus {
    border-color: #3b82f6;
    background-color: #ffffff;
}

.search-input::placeholder {
    color: #94a3b8;
}

/* Catalog Scroll */
.builder-catalog-scroll {
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.catalog-group-name {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0.75rem 0 0.35rem 0.25rem;
}

.catalog-items-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.catalog-field-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    cursor: grab;
    transition: background 0.12s;
    user-select: none;
}

.catalog-field-item:hover {
    background: #f1f5f9;
}

.catalog-field-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-left-col {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    overflow: hidden;
}

.field-glyph {
    font-size: 0.85rem;
    color: #64748b;
    flex-shrink: 0;
}

.field-name-text {
    font-size: 0.8125rem;
    font-weight: 500;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-action-col {
    display: flex;
    align-items: center;
}

.btn-quick-add {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 0.85rem;
    padding: 0 0.25rem;
    line-height: 1;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.catalog-field-item:hover .btn-quick-add {
    opacity: 1;
}

.btn-quick-add:hover {
    color: #2563eb;
    background: #e0e7ff;
}

.field-quick-menu {
    font-size: 0.75rem;
    min-width: 140px;
}

/* ==========================================================================
   Report Layout Section & Drop Zones
   ========================================================================== */
.builder-layout-section {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: 0.5rem;
}

.layout-heading {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #64748b;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 0.1rem;
}

.layout-zone-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-height: 54px;
    transition: border-color 0.15s, background-color 0.15s;
}

.layout-zone-card.drag-over {
    background: #eff6ff;
    border-color: #2563eb;
    border-style: dashed;
}

.zone-top-header {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.zone-icon {
    font-size: 0.8125rem;
    color: #2563eb;
}

.zone-title {
    font-size: 0.6875rem;
    font-weight: 700;
    color: #2563eb;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.zone-items-container {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.zone-empty-msg {
    font-size: 0.75rem;
    font-style: italic;
    color: #94a3b8;
    padding: 0.25rem 0;
}

/* Placed Zone Chips */
.zone-chip {
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: grab;
    transition: all 0.15s;
}

/* White Chip (Columns & Rows) */
.chip-white {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.chip-white:hover {
    border-color: #cbd5e1;
}

/* Blue Chip (Values) */
.chip-blue {
    background: #1d4ed8;
    color: #ffffff;
    box-shadow: 0 1px 2px rgba(29, 78, 216, 0.15);
}

.chip-text {
    max-width: 140px;
    font-size: 0.75rem;
}

.chip-controls {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Value Summary Type Dropdown Select */
.val-summary-dropdown {
    background: #ffffff;
    color: #1e40af;
    border: none;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    cursor: pointer;
    outline: none;
}

/* Action & Close buttons */
.btn-chip-action {
    background: transparent;
    border: none;
    color: #64748b;
    padding: 0;
    font-size: 0.75rem;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.btn-chip-action:hover {
    color: #0f172a;
}

.btn-chip-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 0;
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    margin-left: 0.2rem;
}

.btn-chip-close:hover {
    color: #ef4444;
}

.chip-blue .btn-chip-close {
    color: #ffffff;
    opacity: 0.8;
}

.chip-blue .btn-chip-close:hover {
    opacity: 1;
    color: #fee2e2;
}

/* ==========================================================================
   Filter Modal Popover
   ========================================================================== */
.pivot-filter-popover {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    z-index: 1050;
    width: 320px;
    padding: 1.25rem;
}

.pivot-popover-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1040;
}
