/* DeployHub SQL Query Console - SSMS / Azure Data Studio Studio Theme */

.sql-studio-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    min-height: 600px;
    background-color: #12131a;
    color: #e2e8f0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Toolbar */
.sql-studio-toolbar {
    background-color: #181924;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 6px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    z-index: 10;
}

/* Compact Toolbar Dropdowns */
.compact-select.mud-input-control,
.compact-select .mud-input-control {
    margin-top: 0 !important;
}

.compact-select .mud-input.mud-input-outlined {
    height: 30px !important;
    min-height: 30px !important;
    padding: 0 8px !important;
    border-radius: 4px !important;
    background-color: #151622 !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

.compact-select .mud-input.mud-input-outlined:hover {
    border-color: rgba(255, 255, 255, 0.28) !important;
}

.compact-select .mud-input.mud-input-outlined.mud-input-focused {
    border-color: #3b82f6 !important;
}

.compact-select .mud-input-slot {
    font-size: 0.78rem !important;
    line-height: 28px !important;
    height: 28px !important;
    padding: 0 !important;
    color: #e2e8f0 !important;
}

.compact-select .mud-input-adornment {
    margin: 0 !important;
    height: 28px !important;
}

.compact-select .mud-input-adornment .mud-icon-root {
    font-size: 1.1rem !important;
    color: #94a3b8 !important;
}

.sql-studio-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Object Explorer (Left Panel) */
.sql-object-explorer {
    width: 280px;
    min-width: 240px;
    max-width: 400px;
    background-color: #151620;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, min-width 0.2s ease;
    overflow: hidden;
}

.sql-object-explorer.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
}

.sql-explorer-header {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background-color: #1a1b26;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sql-explorer-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
    font-size: 0.82rem;
}

.sql-explorer-tree .mud-treeview-item-content {
    padding: 2px 4px !important;
    border-radius: 4px;
}

.sql-explorer-tree .mud-treeview-item-content:hover {
    background-color: rgba(255, 255, 255, 0.06) !important;
}

.hover-item {
    transition: background-color 0.15s ease;
}

.hover-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Main Workspace (Editor + Results) */
.sql-workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #1e1e1e;
}

.sql-editor-container {
    height: 48%;
    min-height: 180px;
    position: relative;
    border-bottom: 2px solid #2d3748;
}

#sql-monaco-editor {
    width: 100%;
    height: 100%;
}

.sql-results-container {
    height: 52%;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    background-color: #151620;
    overflow: hidden;
}

/* SSMS Results Grid */
.sql-grid-wrapper {
    flex: 1;
    overflow: auto;
    background-color: #12131a;
    position: relative;
}

.ssms-grid {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.82rem;
    color: #e2e8f0;
    user-select: text;
}

.ssms-grid th {
    background-color: #1c1d29;
    color: #94a3b8;
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 6px 10px;
    text-align: left;
    font-weight: 600;
    border-right: 1px solid #2d3748;
    border-bottom: 2px solid #3b82f6;
    white-space: nowrap;
}

.ssms-grid th .th-datatype {
    font-size: 0.7rem;
    font-weight: normal;
    color: #64748b;
    margin-left: 4px;
}

.ssms-grid td {
    padding: 4px 8px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ssms-grid tr:hover td {
    background-color: rgba(59, 130, 246, 0.12) !important;
}

.ssms-grid .row-index {
    background-color: #181924;
    color: #64748b;
    text-align: right;
    padding: 4px 8px;
    width: 45px;
    min-width: 45px;
    user-select: none;
    font-size: 0.75rem;
    position: sticky;
    left: 0;
    z-index: 4;
    border-right: 1px solid #2d3748;
}

.ssms-grid .row-select-col {
    background-color: #181924;
    color: #64748b;
    padding: 3px 6px;
    width: 64px;
    min-width: 64px;
    user-select: none;
    font-size: 0.75rem;
    position: sticky;
    left: 0;
    z-index: 4;
    border-right: 1px solid #2d3748;
}

.ssms-grid th.row-select-col {
    background-color: #1c1d29;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 6;
    border-bottom: 2px solid #3b82f6;
}

.ssms-grid tr.selected-row td {
    background-color: rgba(59, 130, 246, 0.22) !important;
}

.ssms-grid tr.selected-row td.row-select-col {
    background-color: #1a2538 !important;
}

.ssms-grid .cell-null {
    color: #ffb86c;
    font-style: italic;
    font-weight: 500;
    opacity: 0.85;
}

/* Messages Output */
.sql-messages-panel {
    flex: 1;
    background-color: #0d1117;
    color: #50fa7b;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.85rem;
    padding: 12px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.sql-message-line.error {
    color: #ff5555;
    font-weight: bold;
}

.sql-message-line.success {
    color: #50fa7b;
    font-weight: bold;
}

.sql-message-line.info {
    color: #8be9fd;
}

.sql-message-line.header {
    color: #f1fa8c;
    font-weight: bold;
}

/* Status Bar */
.sql-studio-statusbar {
    background-color: #181924;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 3px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    color: #94a3b8;
}

.sql-status-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Action button in tree */
.tree-action-btn {
    opacity: 0;
    transition: opacity 0.15s ease;
}

.mud-treeview-item:hover .tree-action-btn {
    opacity: 1;
}
