/* Report Studio - Modern Report Builder matching SQL Console design */

.report-studio-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

.report-studio {
    background: #1e1e1e;
    color: #d4d4d4;
    width: 95%;
    max-width: 1600px;
    height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0,0,0,0.6);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
}

/* Header */
.rs-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e3e;
    border-radius: 12px 12px 0 0;
}

.rs-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.rs-title svg {
    color: #a78bfa;
}

.rs-badge {
    font-size: 10px;
    background: #a78bfa;
    color: #fff;
    padding: 3px 10px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.rs-close {
    background: none;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    padding: 0 8px;
    line-height: 1;
}

.rs-close:hover {
    color: #fff;
}

/* Body Layout */
.rs-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar - Tables & Fields */
.rs-sidebar {
    width: 340px;
    background: #252526;
    border-right: 1px solid #3e3e3e;
    display: flex;
    flex-direction: column;
}

.rs-sidebar-section {
    border-bottom: 1px solid #3e3e3e;
}

.rs-sidebar-header {
    padding: 12px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.5px;
    background: #2d2d2d;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rs-sidebar-header .rs-count {
    background: #3e3e3e;
    color: #aaa;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
}

.rs-search {
    padding: 8px 12px;
    border-bottom: 1px solid #3e3e3e;
}

.rs-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #3e3e3e;
    border-radius: 6px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-size: 13px;
}

.rs-search input:focus {
    outline: none;
    border-color: #a78bfa;
}

.rs-search input::placeholder {
    color: #666;
}

/* Table Selector */
.rs-table-select {
    padding: 12px;
}

.rs-table-select select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #3e3e3e;
    border-radius: 6px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-size: 13px;
    cursor: pointer;
}

.rs-table-select select:focus {
    outline: none;
    border-color: #a78bfa;
}

.rs-table-select optgroup {
    background: #252526;
    color: #a78bfa;
    font-weight: 600;
}

.rs-table-select option {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 8px;
}

/* Fields List */
.rs-fields-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.rs-field-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    margin-bottom: 4px;
    min-height: 36px;
}

.rs-field-item:hover {
    background: #3e3e3e;
}

.rs-field-item.selected {
    background: rgba(167, 139, 250, 0.2);
    border: 1px solid rgba(167, 139, 250, 0.4);
}

.rs-field-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.rs-field-icon.dimension {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.rs-field-icon.measure {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.rs-field-icon.date {
    background: rgba(251, 146, 60, 0.2);
    color: #fb923c;
}

.rs-field-name {
    flex: 1;
    font-size: 13px;
    color: #e4e4e7;
    word-wrap: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.rs-field-type {
    font-size: 10px;
    color: #666;
    text-transform: uppercase;
}

/* Main Content Area */
.rs-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Configuration Area */
.rs-config {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: #3e3e3e;
    overflow: hidden;
}

.rs-config-panel {
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rs-config-header {
    padding: 12px 16px;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e3e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rs-config-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rs-config-title svg {
    width: 16px;
    height: 16px;
    color: #888;
}

.rs-config-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Selected Fields (Pills) */
.rs-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

.rs-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #3e3e3e;
    border-radius: 6px;
    font-size: 12px;
    color: #e4e4e7;
}

.rs-pill.dimension {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.rs-pill.measure {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.rs-pill.filter {
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.3);
}

.rs-pill.pivot {
    background: rgba(167, 139, 250, 0.15);
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.rs-pill-remove {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

.rs-pill-remove:hover {
    color: #ef4444;
}

.rs-pill-edit {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 12px;
    line-height: 1;
    opacity: 0.6;
    margin-left: 2px;
    transition: opacity 0.15s;
}

.rs-pill-edit:hover {
    opacity: 1;
}

.rs-pill-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Filter Form */
.rs-filter-form {
    background: #252526;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.rs-filter-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) 110px minmax(200px, 2fr) auto;
    gap: 8px;
    align-items: center;
}

.rs-filter-row select,
.rs-filter-row input {
    padding: 8px 10px;
    border: 1px solid #3e3e3e;
    border-radius: 6px;
    background: #1e1e1e;
    color: #d4d4d4;
    font-size: 12px;
}

.rs-filter-row select:focus,
.rs-filter-row input:focus {
    outline: none;
    border-color: #a78bfa;
}

.rs-filter-remove {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 8px;
    font-size: 16px;
}

.rs-filter-remove:hover {
    color: #ef4444;
}

/* Add Button */
.rs-add-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px dashed #3e3e3e;
    border-radius: 6px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.rs-add-btn:hover {
    border-color: #a78bfa;
    color: #a78bfa;
}

/* Preview Panel */
.rs-preview-panel {
    grid-column: 1 / -1;
    background: #1e1e1e;
    border-top: 1px solid #3e3e3e;
    display: flex;
    flex-direction: column;
    max-height: 300px;
}

.rs-preview-header {
    padding: 10px 16px;
    background: #2d2d2d;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #3e3e3e;
}

.rs-preview-title {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rs-preview-actions {
    display: flex;
    gap: 8px;
}

.rs-preview-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.rs-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.rs-preview-table th {
    background: #2d2d2d;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    color: #a78bfa;
    border-bottom: 1px solid #3e3e3e;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.rs-preview-table td {
    padding: 6px 12px;
    border-bottom: 1px solid #2d2d2d;
    color: #d4d4d4;
}

.rs-preview-table tr:hover td {
    background: #252526;
}

.rs-preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.rs-preview-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.3;
}

/* Footer */
.rs-footer {
    padding: 12px 20px;
    background: #2d2d2d;
    border-top: 1px solid #3e3e3e;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rs-footer-info {
    font-size: 12px;
    color: #888;
}

.rs-footer-actions {
    display: flex;
    gap: 10px;
}

/* Buttons */
.rs-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.rs-btn-default {
    background: #3e3e3e;
    color: #d4d4d4;
    border-color: #3e3e3e;
}

.rs-btn-default:hover {
    background: #4e4e4e;
}

.rs-btn-primary {
    background: #a78bfa;
    color: #fff;
    border-color: #a78bfa;
}

.rs-btn-primary:hover {
    background: #8b5cf6;
}

.rs-btn-success {
    background: #22c55e;
    color: #fff;
    border-color: #22c55e;
}

.rs-btn-success:hover {
    background: #16a34a;
}

.rs-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading State */
.rs-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #888;
}

.rs-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #3e3e3e;
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: rs-spin 0.8s linear infinite;
    margin-right: 12px;
}

@keyframes rs-spin {
    to { transform: rotate(360deg); }
}

/* Edit Mode Indicator */
.rs-edit-banner {
    background: rgba(251, 146, 60, 0.15);
    border: 1px solid rgba(251, 146, 60, 0.3);
    color: #fb923c;
    padding: 10px 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.rs-edit-banner strong {
    color: #fff;
}

/* Scrollbar Styling */
.rs-sidebar::-webkit-scrollbar,
.rs-config-body::-webkit-scrollbar,
.rs-preview-body::-webkit-scrollbar,
.rs-fields-list::-webkit-scrollbar {
    width: 8px;
}

.rs-sidebar::-webkit-scrollbar-track,
.rs-config-body::-webkit-scrollbar-track,
.rs-preview-body::-webkit-scrollbar-track,
.rs-fields-list::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.rs-sidebar::-webkit-scrollbar-thumb,
.rs-config-body::-webkit-scrollbar-thumb,
.rs-preview-body::-webkit-scrollbar-thumb,
.rs-fields-list::-webkit-scrollbar-thumb {
    background: #3e3e3e;
    border-radius: 4px;
}

.rs-sidebar::-webkit-scrollbar-thumb:hover,
.rs-config-body::-webkit-scrollbar-thumb:hover,
.rs-preview-body::-webkit-scrollbar-thumb:hover,
.rs-fields-list::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Empty State */
.rs-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    color: #666;
    text-align: center;
}

.rs-empty-state p {
    margin: 8px 0 0;
    font-size: 12px;
}

/* Date Format Select */
.rs-date-format {
    padding: 4px 8px;
    font-size: 11px;
    background: #2d2d2d;
    border: 1px solid #3e3e3e;
    border-radius: 4px;
    color: #d4d4d4;
    margin-left: 8px;
}


/* Field type casting dropdown */
.rs-field-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.rs-field-main {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.rs-field-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.rs-field-item:hover .rs-field-actions {
    opacity: 1;
}

.rs-type-select {
    font-size: 10px;
    padding: 2px 4px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 3px;
    color: inherit;
    cursor: pointer;
    max-width: 100px;
}

.rs-type-select:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.3);
}

.rs-type-select:focus {
    outline: none;
    border-color: #4fc3f7;
}

.rs-type-select option {
    background: #2d2d2d;
    color: #d4d4d4;
}

/* Drag and Drop Styles */
.rs-field-item[draggable="true"] {
    cursor: grab;
}

.rs-field-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.rs-field-drag-handle {
    color: rgba(255,255,255,0.3);
    font-size: 10px;
    letter-spacing: 1px;
    margin-right: 6px;
    user-select: none;
}

.rs-field-item:hover .rs-field-drag-handle {
    color: rgba(255,255,255,0.6);
}

/* Drop Zone Styles */
.rs-dropzone {
    transition: all 0.2s ease;
}

.rs-dropzone-active {
    background: rgba(79, 195, 247, 0.05);
}

.rs-dropzone-hover {
    background: rgba(79, 195, 247, 0.15) !important;
    border-color: #4fc3f7 !important;
    box-shadow: inset 0 0 20px rgba(79, 195, 247, 0.1);
}

.rs-drop-hint {
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.4);
    border: 2px dashed rgba(255,255,255,0.15);
    border-radius: 6px;
    margin: 8px;
    transition: all 0.2s;
}

.rs-dropzone-hover .rs-drop-hint {
    border-color: #4fc3f7;
    color: #4fc3f7;
    background: rgba(79, 195, 247, 0.1);
}

.rs-drop-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.rs-drop-hint p {
    margin: 0;
    font-size: 12px;
}

/* Filter Autocomplete Styles */
.rs-autocomplete-wrapper {
    position: relative;
    flex: 1;
}

.rs-filter-value {
    width: 100%;
    padding: 6px 10px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 13px;
}

.rs-filter-value:focus {
    outline: none;
    border-color: #4fc3f7;
    background: rgba(255,255,255,0.12);
}

.rs-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    background: #2d2d2d;
    border: 1px solid #4fc3f7;
    border-top: none;
    border-radius: 0 0 4px 4px;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.rs-suggestion-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    color: #d0d0d0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.15s;
}

.rs-suggestion-item:last-child {
    border-bottom: none;
}

.rs-suggestion-item:hover {
    background: rgba(79, 195, 247, 0.15);
    color: #fff;
}

.rs-suggestion-item mark {
    background: rgba(79, 195, 247, 0.3);
    color: #4fc3f7;
    padding: 0 2px;
    border-radius: 2px;
}

/* Scrollbar for suggestions */
.rs-suggestions::-webkit-scrollbar {
    width: 6px;
}

.rs-suggestions::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.rs-suggestions::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

.rs-suggestions::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Toast Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Between operator styling */
.rs-between-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    width: 100%;
}

.rs-between-input {
    flex: 1;
    min-width: 80px;
}

.rs-between-and {
    color: #888;
    font-size: 11px;
    font-style: italic;
}

.rs-no-value {
    color: #666;
    font-size: 11px;
    font-style: italic;
    padding: 6px 8px;
}

.rs-filter-row select optgroup {
    font-weight: 600;
    color: #333;
    background: #f5f5f5;
}

.rs-filter-row select option {
    font-weight: normal;
    padding: 4px 8px;
}


/* Between filter styling */
.rs-filter-between {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.rs-filter-between-sep {
    color: #9ca3af;
    font-size: 12px;
    font-weight: 500;
}

.rs-filter-value-start,
.rs-filter-value-end {
    flex: 1;
    min-width: 120px;
}


/* Order By Styles */
.rs-orderby-item {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.rs-orderby-field {
    flex: 2;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
}

.rs-orderby-dir {
    flex: 1;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 13px;
}

.rs-orderby-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rs-orderby-remove:hover {
    background: rgba(239, 68, 68, 0.4);
}

.rs-pivot-sort {
    margin-bottom: 12px;
}

.rs-pivot-sort-select {
    width: 100%;
    padding: 10px 14px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 8px;
    color: #fff;
    font-size: 13px;
}

.rs-section-header {
    font-size: 11px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

/* Link cells for SFDC/NetSuite links */
.rs-link-cell {
    color: #818cf8;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(99,102,241,0.1);
    font-size: 12px;
    white-space: nowrap;
}
.rs-link-cell:hover {
    background: rgba(99,102,241,0.25);
    text-decoration: underline;
}
