:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.4);
    --bg-dark: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --danger: #ef4444;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Animations */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.5;
    animation: float 10s infinite ease-in-out alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: rgba(139, 92, 246, 0.3);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: rgba(56, 189, 248, 0.2);
    bottom: -200px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 300px;
    height: 300px;
    background: rgba(236, 72, 153, 0.2);
    top: 40%;
    left: 40%;
    animation-duration: 15s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, 50px) scale(1.1); }
}

/* Glassmorphism Utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

/* Layout */
.dashboard {
    width: 100%;
    max-width: 95vw;
    margin: 2rem auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Header & Toggle */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2.5rem;
}

.title-container h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

.title-container h1 span {
    color: var(--primary);
}

.title-container p {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.source-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 12px;
}

.source-toggle button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.source-toggle button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Input Section */
.input-container {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.input-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.3rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
}

.input-methods {
    width: 100%;
    display: flex;
    justify-content: center;
}

.method-content {
    display: none;
    width: 100%;
    max-width: 600px;
    animation: fadeIn 0.3s ease;
}

.method-content.active {
    display: block;
}

.url-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.8rem 1.2rem;
    transition: border-color 0.2s;
}

.url-input-wrapper:focus-within {
    border-color: var(--primary);
}

.url-input-wrapper svg {
    color: var(--text-dim);
    margin-right: 1rem;
}

.url-input-wrapper input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-size: 1rem;
}

.file-upload-wrapper {
    position: relative;
    width: 100%;
}

.file-upload-wrapper input[type="file"] {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    cursor: pointer;
    border: 1px solid var(--glass-border);
    transition: all 0.3s ease;
    color: var(--text-dim);
}

.file-label:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary);
    color: var(--text-main);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.9rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 160px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    padding: 0.9rem 2rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-dim);
}

.filter-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-start;
    align-items: center;
}

.columns-toggle-wrapper {
    margin-left: auto;
    position: relative;
    display: flex;
}

.columns-menu {
    position: absolute;
    width: 250px;
    padding: 1rem;
    display: none;
    flex-direction: column;
    gap: 0.8rem;
    z-index: 999999;
    background: #1e293b;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}

.columns-menu.active {
    display: flex;
}

.columns-menu-header {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.columns-list {
    max-height: 250px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.column-toggle-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
}

.column-toggle-item input {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.column-toggle-item label {
    font-size: 0.9rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Views Setup */
.view-section {
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.4s ease forwards;
}

.view-section.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Filters Section */
.filters-container {
    padding: 1.5rem 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 4rem; /* Increased space between Filter Window and Data Window */
    border-bottom: 1px solid var(--glass-border);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.8rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.search-box svg {
    color: var(--text-dim);
}

.search-box input {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1rem;
    width: 100%;
    outline: none;
}

.dynamic-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.row-range-container {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.range-group {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
}

.range-group label {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
}

.range-group input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    width: 80px;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    outline: none;
    font-size: 0.9rem;
}

.range-group input:focus {
    border-color: var(--primary);
}

.range-group span {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* Header Filter Popup Styles */
#filter-menu-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    pointer-events: none;
    z-index: 99999;
}

th {
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 1rem;
    background: #1e293b;
    border-bottom: 2px solid var(--glass-border);
    white-space: normal;
    word-wrap: break-word;
    min-width: 120px;
}

.resizer {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 6px;
    background: transparent;
    cursor: col-resize;
    transition: background 0.2s;
    z-index: 110;
}

.resizer:hover, .resizer.resizing {
    background: var(--primary);
}

.table-wrapper {
    overflow: auto;
    max-height: 60vh;
    border-radius: 8px;
    position: relative;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed; /* Important for resizing */
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.95rem;
    color: var(--text-main);
    white-space: normal;
    word-wrap: break-word;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.header-filter-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.2rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.header-filter-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.header-filter-btn.active-filter {
    color: var(--primary);
}

.filter-popup {
    position: absolute;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    width: 280px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 1rem;
    pointer-events: auto;
    z-index: 999999;
}

.filter-popup-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-popup-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.2rem;
}

.condition-select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 6px;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

.condition-input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: 6px;
    width: 100%;
    outline: none;
    font-size: 0.9rem;
}

.condition-input::placeholder {
    color: var(--text-dim);
}

.date-range-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-range-container input {
    width: 50%;
}

.value-search {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    width: 100%;
    outline: none;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.value-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
}

.value-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.2rem 0;
    cursor: pointer;
}

.value-item input {
    accent-color: var(--primary);
    cursor: pointer;
}

.value-item label {
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-popup-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.filter-btn-sm {
    flex: 1;
    padding: 0.4rem;
    border-radius: 6px;
    border: none;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-btn-apply {
    background: var(--primary);
    color: white;
}

.filter-btn-apply:hover {
    background: var(--primary-hover);
}

.filter-btn-clear {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.filter-btn-clear:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chart Controls */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.8rem;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-size: 1.1rem;
    color: var(--text-main);
    font-weight: 500;
    border: none;
    padding: 0;
    margin: 0;
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

.chart-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.chart-btn:hover {
    background: var(--primary);
    color: white;
}

.chart-config-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 10;
    border-radius: 12px;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    text-align: center;
    gap: 1rem;
}

.chart-config-overlay.active {
    display: flex;
}

.chart-config-overlay select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.5rem;
    border-radius: 6px;
    width: 100%;
}

.chart-config-overlay button {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
}

/* Dashboard Section */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 1.5rem;
}

.chart-card {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 400px;
}

.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.empty-dashboard {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    color: var(--text-dim);
    text-align: center;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000000;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    width: 90%;
    max-width: 1000px;
    max-height: 80vh;
    padding: 2rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 2rem;
    cursor: pointer;
}

.modal-body {
    overflow: auto;
    flex-grow: 1;
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
}

.preview-table tr {
    cursor: pointer;
    transition: background 0.2s;
}

.preview-table tr:hover {
    background: rgba(139, 92, 246, 0.2);
}

.preview-table td {
    padding: 0.8rem;
    border-bottom: 1px solid var(--glass-border);
    font-size: 0.9rem;
    color: var(--text-main);
}

.preview-table tr.selected {
    background: var(--primary-glow);
}

/* Dashboard Toolbar */
.dashboard-toolbar {
    padding: 1rem;
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1rem;
}

/* Modal Form Styles */
.form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.form-group select option {
    background: var(--bg-dark);
    color: white;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

.chart-options-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1rem;
    border: 1px solid var(--glass-border);
}

.checkbox-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.5rem;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(0,0,0,0.1);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox-item input {
    accent-color: var(--primary);
    cursor: pointer;
}

.checkbox-item label {
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
