/* Bootstrap doesn�t need Tailwind directives, so they�re removed */
/* Define custom properties similar to Tailwind�s :root */
:root {
    --foreground-rgb: 0, 0, 0; /* Text color */
    --background-start-rgb: 252, 252, 252; /* Light gray background start */
    --background-end-rgb: 255, 255, 255; /* White background end */

    --font-inter: 'Inter', sans-serif;
    --font-eb-garamond: 'EB Garamond', serif;
    --font-ocr-a: 'OCR-A', monospace;
    --font-jetbrains: 'JetBrains Mono', monospace;
    /* Bootstrap-compatible custom variables */
    --background: #fff; /* hsl(0, 0%, 100%) */
    --foreground: #0f0f0f; /* hsl(0, 0%, 3.9%) */
    --card: #fff;
    --card-foreground: #0f0f0f;
    --popover: #fff;
    --popover-foreground: #0f0f0f;
    --primary: #1a1a1a; /* hsl(0, 0%, 9%) */
    --primary-foreground: #fafafa; /* hsl(0, 0%, 98%) */
    --secondary: #2d3a31; /* hsl(117, 18%, 21%) */
    --secondary-foreground: #fafafa;
    --muted: #f5f5f5; /* hsl(0, 0%, 96.1%) */
    --muted-foreground: #737373; /* hsl(0, 0%, 45.1%) */
    --accent: #f5f5f5;
    --accent-foreground: #1a1a1a;
    --destructive: #f44336; /* hsl(0, 84.2%, 60.2%) */
    --destructive-foreground: #fafafa;
    --border: #e5e5e5; /* hsl(0, 0%, 89.8%) */
    --input: #e5e5e5;
    --ring: #0f0f0f;
    --radius: 0.5rem;
    --sidebar-background: #fafafa; /* hsl(0, 0%, 98%) */
    --sidebar-foreground: #3f4147; /* hsl(240, 5.3%, 26.1%) */
    --sidebar-primary: #e4e3e3; /* hsl(240, 5.9%, 10%) */
    --sidebar-primary-foreground: #fafafa;
    --sidebar-accent: #f4f5f8; /* hsl(240, 4.8%, 95.9%) */
    --sidebar-accent-foreground: #1a1c2c;
    --sidebar-border: #e8eaed; /* hsl(220, 13%, 91%) */
    --sidebar-ring: #5862e7; /* hsl(217.2, 91.2%, 59.8%) */
}

/* Dark Mode (Manual toggle via class, no prefers-color-scheme) */
body.dark {
    --background: #0f0f0f; /* hsl(0, 0%, 3.9%) */
    --foreground: #fafafa; /* hsl(0, 0%, 98%) */
    --card: #0f0f0f;
    --card-foreground: #fafafa;
    --popover: #0f0f0f;
    --popover-foreground: #fafafa;
    --primary: #fafafa;
    --primary-foreground: #1a1a1a;
    --secondary: #262626; /* hsl(0, 0%, 14.9%) */
    --secondary-foreground: #fafafa;
    --muted: #262626;
    --muted-foreground: #a3a3a3; /* hsl(0, 0%, 63.9%) */
    --accent: #262626;
    --accent-foreground: #fafafa;
    --destructive: #7d2a2e; /* hsl(0, 62.8%, 30.6%) */
    --destructive-foreground: #fafafa;
    --border: #262626;
    --input: #262626;
    --ring: #d4d4d4; /* hsl(0, 0%, 83.1%) */
    --sidebar-background: #1a1c2c; /* hsl(240, 5.9%, 10%) */
    --sidebar-foreground: #f4f5f8; /* hsl(240, 4.8%, 95.9%) */
    --sidebar-primary: #5862e7; /* hsl(224.3, 76.3%, 48%) */
    --sidebar-primary-foreground: #ffffff;
    --sidebar-accent: #272a36; /* hsl(240, 3.7%, 15.9%) */
    --sidebar-accent-foreground: #f4f5f8;
    --sidebar-border: #272a36;
    --sidebar-ring: #5862e7;
}

/* Existing Razor Pages HTML Styles */
html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

/* Body Styles with Bootstrap Compatibility */
body {
    font-family: var(--font-inter); /* Default to Inter */
    background-color: var(--background);
    color: var(--foreground);
    margin: 0; /* Retained from your original */
}

/* Global Styles */
* {
    outline: none;
    border-color: var(--border);
}

/* Bootstrap Focus Styles (Retained from Razor Pages) */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* Custom Font Face */
@font-face {
    font-family: 'OCR-A';
    src: url('../assets/fonts/ocr-a/regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* Message Animation Variables (Adapted for Bootstrap) */
@media (min-width: 640px) {
    .message-enter {
        transform: translateX(20px);
    }

    .message-exit {
        transform: translateX(20px);
    }
}

@media (max-width: 639px) {
    .message-enter {
        transform: translateY(-20px);
    }

    .message-exit {
        transform: translateY(-20px);
    }
}

/* Bootstrap-Compatible Utility Classes */
.text-balance {
    text-wrap: balance; /* Not natively in Bootstrap, but supported in modern browsers */
}

/* Override Bootstrap Defaults with Custom Variables */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
}

.btn-primary:hover {
    background-color: darken(var(--primary), 10%);
    border-color: darken(var(--primary), 10%);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: var(--secondary-foreground);
}

.btn-secondary:hover {
    background-color: darken(var(--secondary), 10%);
    border-color: darken(var(--secondary), 10%);
}

.card {
    background-color: var(--card);
    color: var(--card-foreground);
    border-color: var(--border);
    border-radius: var(--radius);
}

.sidebar {
    background-color: var(--sidebar-background);
    color: var(--sidebar-foreground);
    height: 100%; /* Full height within flex container */
    overflow-x: hidden; /* Prevent horizontal scroll when collapsed */
    min-width: 60px; /* Ensure sidebar never gets too narrow */
    flex-shrink: 0; /* Prevent sidebar from shrinking */
}

.sidebar .nav-link {
    color: var(--sidebar-foreground);
    display: flex;
    align-items: center;
    white-space: nowrap; /* Keep text on one line */
    padding: 0.5rem 1rem; /* Consistent padding */
}

.sidebar .nav-link.active {
    background-color: var(--sidebar-primary);
    color: var(--sidebar-primary-foreground);
}

.sidebar .nav-link:hover {
    background-color: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

.sidebar .nav-link.collapsed span {
    display: none; /* Hide text when collapsed */
}

.sidebar .nav-link i {
    min-width: 1.5rem; /* Ensure icon space */
    font-size: 1.25rem; /* Consistent icon size */
}

.sidebar .sidebar-heading {
    white-space: nowrap; /* Prevent "Menu" from wrapping */
}

.sidebar.collapsed .sidebar-heading {
    display: none; /* Hide "Menu" title when collapsed */
}

.sidebar .sidebar-heading {
    white-space: nowrap; /* Prevent "Menu" from wrapping */
}

.navbar-brand svg:first-child {
    opacity: 0;
}

.navbar-brand svg:last-child {
    opacity: 1;
}

.navbar-brand:hover svg:first-child {
    opacity: 1;
}

.navbar-brand:hover svg:last-child {
    opacity: 0;
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba(0, 0, 0, 0.55)' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 Ap�s5h22M4 12h22M4 19h22'/%3e%3c/svg%3e") !important;
}

.transition-opacity {
    transition: opacity 0.3s ease;
}

/* Darken secondary color on hover */
.hover-bg-secondary:hover {
    background-color: darken(#2d3a31, 5%); /* Matches hover:bg-secondary/95 */
}

/* Scale up on hover */
.hover-scale-102:hover {
    transform: scale(1.02);
}

/* Table header styles for sortable columns */
.table th.sortable a {
    text-decoration: none; /* No underline */
    color: #005566; /* Distinct teal for sortable links */
    font-weight: 600; /* Semi-bold for professional look */
    transition: color 0.2s ease, background-color 0.2s ease; /* Smooth hover */
}

    .table th.sortable a:hover {
        color: #007bff; /* Bootstrap primary on hover */
        background-color: #f8f9fa; /* Light background on hover */
        border-radius: 4px; /* Subtle rounding */
    }

.table th.sortable {
    vertical-align: middle; /* Center vertically */
    line-height: 1.3; /* Compact line height */
    padding: 0.5rem; /* Compact padding */
}

    .table th.sortable .bi-arrow-down-up {
        margin-left: 0.25rem; /* Space between text and icon */
        font-size: 0.9em; /* Slightly smaller icon */
        vertical-align: middle; /* Align with text */
    }

    .table th.sortable .sort-state {
        margin-left: 0.25rem; /* Space for (ASC)/(DESC) */
        font-size: 0.85em; /* Smaller text for state */
        color: #6c757d; /* Muted gray for state */
    }

/* New styles for table cell links */
.table td {
    vertical-align: middle; /* Center vertically */
}
    .table td a {
        text-decoration: none; /* No underline */
        color: #005566; /* Match sortable header color */
        font-weight: 500; /* Slightly less bold than headers */
    }

        .table td a:hover {
            color: #007bff; /* Same hover color as headers */
            background-color: #f8f9fa; /* Subtle hover background */
            border-radius: 4px;
            padding: 0.1rem 0.2rem; /* Minimal padding for hover effect */
        }

/* Main content area */
main[role="main"] {
    overflow-y: auto; /* Allow vertical scrolling */
    overflow-x: hidden; /* Prevent horizontal scroll */
    max-height: calc(100vh - 60px - 40px); /* Viewport height minus header and footer */
}

/* Flex container for sidebar + main */
.d-flex.flex-grow-1 {
    overflow: hidden; /* Prevent overflow from breaking layout */
    min-height: 0; /* Allow flex items to shrink below content size */
}

/* Menu submenu styles */
.menu-toggle {
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.submenu-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
}

.menu-toggle[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

.submenu-link {
    font-size: 0.9rem;
    padding: 0.4rem 1rem;
}

.submenu-link:hover {
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
}

.submenu-link.active {
    background-color: rgba(0, 123, 255, 0.1);
    color: #007bff !important;
    font-weight: 500;
    border-left: 3px solid #007bff;
}

.collapse {
    transition: height 0.3s ease;
}

/* Parent menu item active state */
.menu-toggle.active {
    background-color: rgba(0, 123, 255, 0.05);
    font-weight: 500;
}

/* Audit Metadata Editor Styles */
.audit-metadata-editor {
    font-family: var(--font-jetbrains), 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: vertical;
    min-height: 150px;
}

.audit-metadata-editor.is-valid {
    border-color: #198754;
    background-image: none;
}

.audit-metadata-editor.is-invalid {
    border-color: #dc3545;
    background-image: none;
}

.audit-metadata-editor:focus {
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Audit Metadata Viewer Styles (Read-only) */
.audit-metadata-viewer {
    font-family: var(--font-jetbrains), 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

body.dark .audit-metadata-viewer {
    background-color: #1a1a1a;
    border-color: #3a3a3a;
    color: #e0e0e0;
}
