/* CSS Variables for theming */
:root {
    --bg-color: #f5f7fa;
    --text-color: #212529;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --sidebar-bg: #FFFFFF;
    --hover-bg: #e9ecef;
    --link-color: #0071e3;
    --input-bg: #ffffff;
    --input-border: #ced4da;
    --muted-text: #6c757d;
    --top-row-bg: #ffffff;
    --content-bg: #f5f7fa;
}

[data-theme="dark"] {
    --bg-color: #1A1A1A;
    --text-color: #E8E8E8;
    --card-bg: #2A2A2A;
    --border-color: #404040;
    --sidebar-bg: #2A2A2A;
    --hover-bg: #3A3A3A;
    --link-color: #BECF91;
    --input-bg: #2A2A2A;
    --input-border: #404040;
    --muted-text: #A0A0A0;
    --top-row-bg: #2A2A2A;
    --content-bg: #1A1A1A;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-color);
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #404040;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: #505050;
}

html, body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1:focus {
    outline: none;
}

a, .btn-link {
    color: var(--link-color);
}

/* Layout */
.page {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    background-color: var(--content-bg);
}

.content {
    background-color: var(--content-bg);
}

.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    flex-shrink: 0;
}

.top-row {
    background-color: var(--top-row-bg);
    border-bottom: 1px solid var(--border-color);
    justify-content: flex-end;
    height: 3.5rem;
    display: flex;
    align-items: center;
}

.top-row a,
.top-row .btn-link {
    margin-left: 1.5rem;
    color: var(--link-color);
    text-decoration: none;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.top-row a:hover,
.top-row .btn-link:hover {
    text-decoration: underline;
}

@media (min-width: 768px) {
    .page {
        flex-direction: row;
        height: 100vh;
    }

    .sidebar {
        position: sticky;
        top: 0;
        height: 100vh;
        width: 280px;
    }

    .nav-menu {
        height: 100%;
    }

    main {
        height: 100vh;
        overflow-y: auto;
    }
}

.validation-message {
    color: #e50000;
}

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: #e0e0e0;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    min-width: 250px;
    margin-bottom: 10px;
}

.card {
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-card {
    transition: all 0.2s ease;
}

.message-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.message-card.selected {
    border-color: #0071e3;
    background-color: #f0f8ff;
}

pre {
    background-color: #f8f9fa; /* Light mode bg */
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    color: #212529; /* Light mode text */
    border: 1px solid var(--border-color);
}

[data-theme="dark"] pre {
    background-color: transparent;
    color: #e0e0e0;
    border-color: #404040;
}

/* Fix table colors in dark mode */
.table {
    color: var(--text-color);
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-color);
    --bs-table-border-color: var(--border-color);
}

.btn-group-sm > .btn {
    font-size: 0.875rem;
}

/* Navigation - 3-section layout */
.nav-menu {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.nav-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.nav-favorites-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem 0;
}

.nav-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.user-section {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

.user-section:hover {
    background-color: var(--hover-bg);
}

.dark-mode-toggle {
    padding: 0.5rem;
}

/* Drag and drop styles */
.recent-namespace-tile[draggable="true"] {
    cursor: move;
}

.recent-namespace-tile[draggable="true"]:active {
    opacity: 0.5;
}

.folder-header.drag-over {
    background-color: var(--link-color) !important;
    color: white;
    border-radius: 4px;
    transition: all 0.2s ease;
}

[data-theme="dark"] .folder-header.drag-over {
    background-color: #BECF91 !important;
    color: #0D022C;
}

.nav-link {
    display: flex;
    align-items: center;
    line-height: 3rem;
    color: #333;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
}

.nav-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    color: #0071e3;
}

.nav-link.active {
    background-color: #0071e3;
    color: white;
}

.nav-link span {
    margin-right: 0.5rem;
}

/* Namespace cards */
.namespace-card {
    transition: all 0.2s ease;
    position: relative;
}

.namespace-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    border-color: #0071e3;
}

.favorite-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    color: #ffc107;
    text-shadow: 0 0 3px rgba(0,0,0,0.3);
    transition: transform 0.2s ease;
    z-index: 10;
}

.favorite-btn:hover {
    transform: scale(1.2);
}

.favorite-btn.favorited {
    color: #ffc107;
}

.favorite-btn.not-favorited {
    color: #ccc;
}

/* Recent namespace tiles */
.recent-namespace-tile {
    color: var(--text-color);
    text-decoration: none;
    border-radius: 6px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    display: block;
}

.recent-namespace-tile:hover {
    background-color: var(--hover-bg);
    border-color: var(--link-color);
    transform: translateX(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recent-namespace-tile .text-muted {
    font-size: 0.75rem;
}

/* User link */
.user-link {
    color: #0071e3;
    text-decoration: none;
}

.user-link:hover {
    text-decoration: underline;
}

/* Message list */
.message-list .message-item {
    cursor: pointer;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.message-list .message-item:hover {
    background-color: var(--hover-bg);
    border-left-color: var(--link-color);
}

.message-list .message-item.selected {
    background-color: #e7f3ff;
    border-left-color: var(--link-color);
}

[data-theme="dark"] .message-list .message-item.selected {
    background-color: #BECF91;
    color: #0D022C;
}

/* Apply theme variables to components */
.card {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

.list-group-item {
    background-color: var(--card-bg);
    border-color: var(--border-color);
    color: var(--text-color);
}

.list-group-item:hover {
    background-color: var(--hover-bg);
}

.form-control,
.form-select,
textarea {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--text-color);
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    background-color: var(--input-bg);
    color: var(--text-color);
}

.modal-content {
    background-color: var(--card-bg);
    color: var(--text-color);
}

.modal-header,
.modal-footer {
    border-color: var(--border-color);
}

.alert {
    background-color: var(--card-bg);
    border-color: var(--border-color);
}

.alert-info {
    background-color: #e7f5ff; /* Calmer blue */
    border-color: #b6effb;
    color: #004085;
}

[data-theme="dark"] .alert-info {
    background-color: #0e2a47; /* Darker blue for dark mode */
    border-color: #103f6b;
    color: #b8daff;
}

.text-muted {
    color: var(--muted-text) !important;
}

pre, code {
    background-color: var(--card-bg);
    color: var(--text-color);
}

.namespace-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-color: #BECF91;
}

[data-theme="dark"] .namespace-card:hover {
    box-shadow: 0 4px 8px rgba(255, 255, 255, 0.1);
    border-color: #BECF91;
}

/* Explorer Page - 3 Section Layout */
.explorer-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.explorer-header {
    flex-shrink: 0;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
}

.explorer-namespace-title {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
}

.explorer-entities {
    flex-shrink: 0;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--card-bg);
    max-height: 30vh;
}

.explorer-entities-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    height: 100%;
}

.explorer-entities-grid-3col {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.75rem;
    height: 100%;
}

.entity-column {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.entity-column-header {
    flex-shrink: 0;
    font-weight: 600;
    padding: 0.5rem;
    background-color: var(--hover-bg);
    border-radius: 4px 4px 0 0;
    border-bottom: 2px solid var(--border-color);
}

.entity-list-scroll {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 0 0 4px 4px;
    background-color: var(--input-bg);
}

.entity-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s ease;
}

.entity-item:hover {
    background-color: var(--hover-bg);
}

.entity-item.active {
    background-color: var(--link-color);
    color: white;
}

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

.explorer-messages {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 1rem;
    overflow: hidden;
}

.explorer-messages-header {
    flex-shrink: 0;
    margin-bottom: 0.75rem;
}

.explorer-messages-content {
    flex: 1;
    display: flex;
    gap: 1rem;
    min-height: 0;
}

.explorer-messages-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
}

.explorer-actions-sidebar {
    flex-shrink: 0;
    width: 200px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.action-btn-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--card-bg);
}

.action-btn-group-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--muted-text);
    margin-bottom: 0.25rem;
}

.dlq-toggle-group {
    background-color: var(--hover-bg);
}

.dlq-toggle-group .form-check-label {
    font-weight: 500;
    color: var(--text-color);
}

.dlq-toggle-group .form-check-input {
    border: 2px solid var(--border-color);
}

.dlq-toggle-group .form-check-input:checked {
    background-color: var(--link-color);
    border-color: var(--link-color);
}

[data-theme="dark"] .dlq-toggle-group {
    border-color: #505050;
}

[data-theme="dark"] .dlq-toggle-group .form-check-input {
    background-color: #3A3A3A;
    border: 2px solid #606060;
}

[data-theme="dark"] .dlq-toggle-group .form-check-input:checked {
    background-color: #BECF91;
    border-color: #BECF91;
}
