/* CSS Variables for Premium Look */
:root {
    --grid-border: #e2e8f0;
    --grid-bg: #ffffff;
    --grid-header-bg: #f8fafc;
    --grid-row-hover: #f1f5f9;
    --grid-selection-bg: rgba(59, 130, 246, 0.1);
    --grid-selection-border: #3b82f6;
    --grid-text: #334155;
    --primary: #3b82f6;
}

.vg-group-panel {
    background: #f1f5f9;
    padding: 0.5rem;
    border-bottom: 1px solid var(--grid-border);
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-height: 20px;
}

body {
    margin: 0;
    font-family: 'Inter', sans-serif;
    color: var(--grid-text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Fix double scrollbar by disabling body scroll */
}

/* Toolbar */
.toolbar {
    flex: 0 0 auto;
    /* Fixed height */
    padding: 1rem;
    border-bottom: 1px solid var(--grid-border);
    display: flex;
    gap: 1rem;
    align-items: center;
    background: white;
}

.search-input {
    padding: 0.5rem 1rem;
    border: 1px solid var(--grid-border);
    border-radius: 6px;
    width: 300px;
    font-size: 0.9rem;
}

.btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1px solid var(--grid-border);
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

.btn:hover {
    background: var(--grid-row-hover);
}

/* Virtual Grid Container */
#grid-container {
    flex: 1;
    overflow: hidden;
    /* Ensure container fits in flex parent */
    position: relative;
    outline: none;
    /* remove focus ring */
}

.vg-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--grid-border);
}

.vg-header {
    background: var(--grid-header-bg);
    border-bottom: 1px solid var(--grid-border);
    overflow: hidden;
    flex: 0 0 auto;
}

.vg-header-row {
    display: flex;
}

.vg-header-cell {
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--grid-border);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    user-select: none;
    position: relative;
    /* For resize handle */
}

/* Modal */
.vg-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.vg-modal {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    width: 400px;
    max-width: 90vw;
}

.vg-modal h3 {
    margin-top: 0;
}

.vg-form-group {
    margin-bottom: 15px;
}

.vg-form-group label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 5px;
    color: #64748b;
}

.vg-form-group input,
.vg-form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: inherit;
    box-sizing: border-box;
}

.vg-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.vg-header-cell:hover {
    background: #e2e8f0;
}

.vg-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 10;
}

.vg-resize-handle:hover {
    background: var(--primary);
}

.vg-viewport {
    flex: 1;
    overflow: auto;
    position: relative;
}

.vg-content {
    position: relative;
    /* Height set by JS */
}

.vg-row {
    display: flex;
    border-bottom: 1px solid #f1f5f9;
    box-sizing: border-box;
    background: white;
}

.vg-row:hover {
    background-color: var(--grid-row-hover);
}

.vg-cell {
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    border-right: 1px solid transparent;
    /* invisible border usually */
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

/* Selection */
.vg-row.selected {
    background-color: var(--grid-selection-bg);
}

.col-selected {
    background-color: rgba(59, 130, 246, 0.05);
}

.vg-row.selected .col-selected {
    border: 2px solid var(--grid-selection-border);
    /* Highlighting the intersection */
}

/* Groups */
.vg-group-row {
    background: #fff7ed;
    color: #c2410c;
    font-weight: bold;
    padding-left: 1rem;
    align-items: center;
}

/* Edit Input */
.vg-edit-input {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    outline: 2px solid var(--primary);
    padding: 0 0.5rem;
}

/* Context Menu */
#vg-context-menu {
    display: none;
    position: fixed;
    z-index: 1000;
    width: 150px;
    background: white;
    border: 1px solid var(--grid-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-radius: 6px;
}

#vg-context-menu div {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

#vg-context-menu div:hover {
    background: var(--grid-row-hover);
}