/**
 * RackLens Theme System
 * CSS variables for light/dark mode support
 * Custom color palette and typography
 */

/* Google Fonts - Inter */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* ========================================
       TYPOGRAPHY
       ======================================== */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    /* Font sizes */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */

    /* ========================================
       COLOR PALETTE - Tech/Cyber Theme
       ======================================== */

    /* Primary - Indigo */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --primary-rgb: 99, 102, 241;

    /* Accent - Teal */
    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --accent-light: #ccfbf1;
    --accent-rgb: 20, 184, 166;

    /* ========================================
       LIGHT MODE (default)
       ======================================== */

    /* Backgrounds */
    --bg-body: #f3f4f6;
    --bg-card: #ffffff;
    --bg-elevated: #e5e7eb;
    --bg-input: #ffffff;

    /* Text */
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Borders */
    --border-color: #cbd5e1;
    --border-light: #f1f5f9;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    /* Status Colors (consistent across modes) */
    --success: #22c55e;
    --success-bg: #dcfce7;
    --success-rgb: 34, 197, 94;
    --warning: #f59e0b;
    --warning-bg: #fef3c7;
    --warning-rgb: 245, 158, 11;
    --danger: #ef4444;
    --danger-bg: #fee2e2;
    --danger-rgb: 239, 68, 68;
    --info: #3b82f6;
    --info-bg: #dbeafe;
    --info-rgb: 59, 130, 246;

    /* Table */
    --table-hover-bg: #f8fafc;
    --table-stripe-bg: #f8fafc;

    /* Modal overlay */
    --modal-backdrop: rgba(0, 0, 0, 0.5);
}

/* ========================================
   DARK MODE
   ======================================== */
body.dark-mode {
    /* Backgrounds */
    --bg-body: #0f172a;
    --bg-card: #1e293b;
    --bg-elevated: #334155;
    --bg-input: #1e293b;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: #475569;
    --border-light: #334155;

    /* Shadows (more subtle in dark mode) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5);

    /* Status Colors (adjusted for dark mode) */
    --success-bg: rgba(34, 197, 94, 0.15);
    --warning-bg: rgba(245, 158, 11, 0.15);
    --danger-bg: rgba(239, 68, 68, 0.15);
    --info-bg: rgba(59, 130, 246, 0.15);

    /* Table */
    --table-hover-bg: #334155;
    --table-stripe-bg: rgba(51, 65, 85, 0.5);

    /* Modal overlay */
    --modal-backdrop: rgba(0, 0, 0, 0.7);
}

/* ========================================
   BASE STYLES USING VARIABLES
   ======================================== */

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

code, pre, .monospace {
    font-family: var(--font-mono);
}

/* ========================================
   BOOTSTRAP COLOR OVERRIDES
   ======================================== */

/* Primary buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

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

.btn-primary:active {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Outline primary buttons */
.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

/* Text and background utilities */
.text-primary {
    color: var(--primary) !important;
}

.bg-primary {
    background-color: var(--primary) !important;
}

/* Links */
a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-hover);
}

/* Text inputs - Brighter purple glow */
input[type="text"]:focus,
input[type="search"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
textarea.form-control:focus {
    border-color: rgba(147, 51, 234, 0.3);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), 0 0 10px 2px rgba(147, 51, 234, 0.4) !important;
    border-radius: 0.375rem !important;
}

body.dark-mode input[type="text"]:focus,
body.dark-mode input[type="search"]:focus,
body.dark-mode input[type="email"]:focus,
body.dark-mode input[type="password"]:focus,
body.dark-mode input[type="number"]:focus,
body.dark-mode input[type="url"]:focus,
body.dark-mode input[type="tel"]:focus,
body.dark-mode textarea.form-control:focus {
    border-color: rgba(192, 132, 252, 0.4);
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.6), 0 0 10px 2px rgba(192, 132, 252, 0.5) !important;
    border-radius: 0.375rem !important;
}

/* Selects - Softer glow */
.form-select:focus,
select:focus {
    border-color: rgba(147, 51, 234, 0.3);
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25), 0 0 4px 1px rgba(147, 51, 234, 0.15) !important;
}

body.dark-mode .form-select:focus,
body.dark-mode select:focus {
    border-color: rgba(192, 132, 252, 0.4);
    box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.3), 0 0 4px 1px rgba(192, 132, 252, 0.2) !important;
}

/* Accent color utilities */
.text-accent {
    color: var(--accent) !important;
}

.bg-accent {
    background-color: var(--accent) !important;
}

.btn-accent {
    background-color: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-accent:hover {
    background-color: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

/* Badge overrides */
.badge.bg-primary {
    background-color: var(--primary) !important;
}

/* Status colors */
.badge.bg-success { background-color: var(--success) !important; }
.badge.bg-warning { background-color: var(--warning) !important; }
.badge.bg-danger { background-color: var(--danger) !important; }
.badge.bg-info { background-color: var(--info) !important; }

/* Nav and tabs */
.nav-link {
    color: var(--text-secondary);
}

.nav-link:hover {
    color: var(--primary);
}

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

/* Pagination */
.page-link {
    color: var(--primary);
}

.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.card-header {
    background-color: var(--bg-elevated);
    border-bottom-color: var(--border-color);
}

.card-footer {
    background-color: var(--bg-elevated);
    border-top-color: var(--border-color);
}

/* Forms */
.form-control,
.form-select {
    background-color: var(--bg-input);
    border-color: var(--border-color);
    color: var(--text-primary);
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

input[type="text"].form-control:focus,
input[type="search"].form-control:focus,
input[type="email"].form-control:focus,
input[type="password"].form-control:focus,
input[type="number"].form-control:focus,
input[type="url"].form-control:focus,
input[type="tel"].form-control:focus {
    background-color: var(--bg-input);
    border-color: rgba(147, 51, 234, 0.3);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), 0 0 10px 2px rgba(147, 51, 234, 0.4) !important;
    border-radius: 0.375rem !important;
}

.form-select:focus {
    background-color: var(--bg-input);
    border-color: rgba(147, 51, 234, 0.3);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25), 0 0 4px 1px rgba(147, 51, 234, 0.15) !important;
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-control:disabled,
.form-select:disabled {
    background-color: var(--bg-elevated);
    color: var(--text-muted);
}

.form-label {
    color: var(--text-primary);
}

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

.input-group-text {
    background-color: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* Tables */
.table {
    color: var(--text-primary);
    border-color: var(--border-color);
}

.table > thead {
    background-color: var(--bg-elevated);
}

.table > thead > tr > th {
    border-bottom-color: var(--border-color);
    color: var(--text-secondary);
}

.table > tbody > tr > td {
    border-bottom-color: var(--border-color);
}

/* Fix table body background in dark mode */
body.dark-mode .table > tbody > tr {
    background-color: var(--bg-card) !important;
}

body.dark-mode .table,
body.dark-mode .table-responsive {
    background-color: var(--bg-card) !important;
}

body.dark-mode #inventoryTable,
body.dark-mode #inventoryTable tbody,
body.dark-mode #inventoryTable tbody tr,
body.dark-mode #inventoryTable tbody tr td {
    background-color: var(--bg-card) !important;
    color: var(--text-primary);
}

body.dark-mode #inventoryTable thead,
body.dark-mode #inventoryTable thead tr,
body.dark-mode #inventoryTable thead tr th {
    background-color: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
    border-bottom: 2px solid var(--border-color) !important;
}

/* ========================================
   TABLE-DARK THEME OVERRIDES
   ======================================== */

/* Light mode: table-dark uses elevated background for distinction */
body:not(.dark-mode) .table-dark,
body:not(.dark-mode) .table-dark > thead,
body:not(.dark-mode) .table-dark > tbody > tr {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

body:not(.dark-mode) .table-dark > thead > tr > th {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body:not(.dark-mode) .table-dark > tbody > tr > td {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Dark mode: table-dark uses card background */
body.dark-mode .table-dark,
body.dark-mode .table-dark > thead,
body.dark-mode .table-dark > tbody > tr {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .table-dark > thead > tr > th {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .table-dark > tbody > tr > td {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

.table-hover > tbody > tr:hover {
    background-color: var(--table-hover-bg);
}

.table-striped > tbody > tr:nth-of-type(odd) {
    background-color: var(--table-stripe-bg);
}

/* Modals */
.modal-content {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

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

.modal-backdrop {
    background-color: var(--modal-backdrop);
}

/* Buttons - outline variants */
.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.btn-outline-secondary:hover {
    background-color: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Close button */
.btn-close {
    filter: var(--btn-close-filter, none);
}

body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Dropdowns */
.dropdown-menu {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    box-shadow: var(--shadow-lg);
}

.dropdown-item {
    color: var(--text-primary);
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.dropdown-divider {
    border-top-color: var(--border-color);
}

/* List groups */
.list-group-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    color: var(--text-primary);
}

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

/* Alerts */
.alert {
    border: none;
}

/* Nav tabs */
.nav-tabs {
    border-bottom-color: var(--border-color);
}

.nav-tabs .nav-link {
    color: var(--text-secondary);
}

.nav-tabs .nav-link:hover {
    border-color: var(--border-color);
}

.nav-tabs .nav-link.active {
    background-color: var(--bg-card);
    border-color: var(--border-color);
    border-bottom-color: var(--bg-card);
    color: var(--text-primary);
}

/* Accordion */
.accordion-item {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.accordion-button {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

.accordion-button:not(.collapsed) {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

.accordion-button::after {
    filter: var(--accordion-arrow-filter, none);
}

body.dark-mode .accordion-button::after {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* Progress bars */
.progress {
    background-color: var(--bg-elevated);
}

/* Badges - adjust for dark mode visibility */
body.dark-mode .badge.bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

/* Text utilities */
.text-muted {
    color: var(--text-muted) !important;
}

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

/* Border utilities */
.border {
    border-color: var(--border-color) !important;
}

.border-top,
.border-bottom,
.border-start,
.border-end {
    border-color: var(--border-color) !important;
}

/* Background utilities */
.bg-light {
    background-color: var(--bg-elevated) !important;
}

body.dark-mode .bg-white {
    background-color: var(--bg-card) !important;
}

/* Scrollbar styling for dark mode */
body.dark-mode ::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.dark-mode ::-webkit-scrollbar-track {
    background: var(--bg-body);
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

body.dark-mode ::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

/* ========================================
   THEME TOGGLE BUTTON
   ======================================== */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    transform: scale(1.05);
}

/* ========================================
   LOCK SCREEN DARK MODE SUPPORT
   ======================================== */
#lockScreen .card,
#setupEncryptionScreen .card {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

#lockScreen .bg-light,
#setupEncryptionScreen .bg-light {
    background-color: var(--bg-body) !important;
}

body.dark-mode #lockScreen .bg-light,
body.dark-mode #setupEncryptionScreen .bg-light {
    background-color: var(--bg-body) !important;
}

/* ========================================
   CARD VISIBILITY FIXES
   ======================================== */

/* Fix card borders to be visible in light mode */
.card {
    border: 1px solid var(--border-color) !important;
}

/* Fix card title readability in dark mode */
.card-title,
.card .fw-bold:not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-primary),
.card h5:not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-primary),
.card h4:not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-primary),
.card h3:not(.text-success):not(.text-danger):not(.text-warning):not(.text-info):not(.text-primary) {
    color: var(--text-primary) !important;
}

/* ========================================
   BADGE FIXES
   ======================================== */

/* Ensure badge text is always visible */
.badge {
    color: #fff !important;
}

/* Fix semi-transparent badges on index.html tool cards */
.badge.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.15) !important;
    color: var(--primary) !important;
}

.badge.bg-secondary.bg-opacity-10 {
    background-color: var(--bg-elevated) !important;
    color: var(--text-secondary) !important;
}

/* Status badges need white text */
.badge.bg-success,
.badge.bg-warning,
.badge.bg-danger,
.badge.bg-info,
.badge.bg-secondary {
    color: #fff !important;
}

/* Warning badge needs dark text for contrast */
.badge.bg-warning {
    color: #000 !important;
}

/* ========================================
   ALERT BOX FIXES (cableman, coolman, etc)
   ======================================== */

/* Fix alert boxes in dark mode */
body.dark-mode .alert-success {
    background-color: var(--success-bg);
    color: var(--text-primary);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

body.dark-mode .alert-success .alert-heading,
body.dark-mode .alert-success h5,
body.dark-mode .alert-success .fw-bold {
    color: var(--success) !important;
}

body.dark-mode .alert-info {
    background-color: var(--info-bg);
    color: var(--text-primary);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

body.dark-mode .alert-warning {
    background-color: var(--warning-bg);
    color: var(--text-primary);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

body.dark-mode .alert-danger {
    background-color: var(--danger-bg);
    color: var(--text-primary);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Fix .bg-white boxes inside alerts for dark mode */
body.dark-mode .alert .bg-white {
    background-color: var(--bg-card) !important;
}

body.dark-mode .alert .bg-white .text-muted {
    color: var(--text-secondary) !important;
}

body.dark-mode .alert .bg-white .h4,
body.dark-mode .alert .bg-white .fw-bold {
    color: var(--text-primary) !important;
}

/* ========================================
   STAT CARD / INFO BOX FIXES
   ======================================== */

/* Fix top bar stat cards (cableman, coolman, etc) */
.card .display-6,
.card .display-5,
.card .display-4,
.card .h4,
.card .h5 {
    color: var(--text-primary);
}

/* Fix stat box text visibility */
.card .text-muted {
    color: var(--text-secondary) !important;
}

/* Fix bg-primary-subtle and similar Bootstrap 5.3 utilities */
.bg-primary-subtle {
    background-color: rgba(var(--primary-rgb), 0.1) !important;
}

body.dark-mode .bg-primary-subtle {
    background-color: rgba(var(--primary-rgb), 0.2) !important;
}

/* ========================================
   INVENTORY & TOOL-SPECIFIC FIXES
   ======================================== */

/* Fix inventory card wrapper in dark mode */
body.dark-mode .inventory-card-wrapper .card,
body.dark-mode .card[class*="border-"] {
    background-color: var(--bg-card) !important;
}

/* Fix bright boxes in dark mode */
body.dark-mode .bg-light,
body.dark-mode .bg-white {
    background-color: var(--bg-card) !important;
}

/* Fix source/destination location boxes */
body.dark-mode .rounded.p-3,
body.dark-mode .rounded-3.p-3 {
    background-color: var(--bg-elevated) !important;
}

/* ========================================
   BUTTON FIXES
   ======================================== */

/* Ensure success buttons stay green in both modes */
.btn-success {
    background-color: var(--success) !important;
    border-color: var(--success) !important;
    color: #fff !important;
}

.btn-success:hover {
    background-color: #16a34a !important;
    border-color: #16a34a !important;
}

/* ========================================
   TEXT READABILITY FIXES
   ======================================== */

/* Improve text-muted visibility in light mode */
.text-muted {
    color: #64748b !important;
}

body.dark-mode .text-muted {
    color: #94a3b8 !important;
}

/* Fix small/secondary text */
.small, small {
    color: var(--text-secondary);
}

body.dark-mode .small,
body.dark-mode small {
    color: var(--text-secondary);
}

/* ========================================
   STAT HEADER FIXES (cableman, coolman, etc)
   ======================================== */

/* Fix header stats text */
#headerStats .h4,
#headerStats .fw-bold {
    color: var(--text-primary) !important;
}

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

/* ========================================
   BG-OPACITY CARD FIXES
   ======================================== */

/* Fix cards with bg-primary bg-opacity-10 */
.card.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.1) !important;
    border: 1px solid rgba(var(--primary-rgb), 0.2) !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.15) !important;
    border: 1px solid rgba(var(--primary-rgb), 0.25) !important;
}

.card.bg-primary.bg-opacity-10 .text-muted {
    color: var(--text-secondary) !important;
}

.card.bg-primary.bg-opacity-10 .text-primary {
    color: var(--primary) !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 .text-primary {
    color: #a5b4fc !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 .text-muted {
    color: var(--text-secondary) !important;
}

/* Same for other color variants */
.card.bg-success.bg-opacity-10 {
    background-color: rgba(34, 197, 94, 0.1) !important;
    border: 1px solid rgba(34, 197, 94, 0.2) !important;
}

body.dark-mode .card.bg-success.bg-opacity-10 {
    background-color: rgba(34, 197, 94, 0.15) !important;
}

.card.bg-danger.bg-opacity-10 {
    background-color: rgba(239, 68, 68, 0.1) !important;
    border: 1px solid rgba(239, 68, 68, 0.2) !important;
}

body.dark-mode .card.bg-danger.bg-opacity-10 {
    background-color: rgba(239, 68, 68, 0.15) !important;
}

.card.bg-warning.bg-opacity-10 {
    background-color: rgba(245, 158, 11, 0.1) !important;
    border: 1px solid rgba(245, 158, 11, 0.2) !important;
}

body.dark-mode .card.bg-warning.bg-opacity-10 {
    background-color: rgba(245, 158, 11, 0.15) !important;
}

.card.bg-info.bg-opacity-10 {
    background-color: rgba(59, 130, 246, 0.1) !important;
    border: 1px solid rgba(59, 130, 246, 0.2) !important;
}

body.dark-mode .card.bg-info.bg-opacity-10 {
    background-color: rgba(59, 130, 246, 0.15) !important;
}

/* Fix text inside these cards - preserve Bootstrap color classes */
.card.bg-primary.bg-opacity-10 .h3.text-primary {
    color: var(--primary) !important;
}

.card.bg-success.bg-opacity-10 .h3.text-success {
    color: var(--success) !important;
}

.card.bg-danger.bg-opacity-10 .h3.text-danger {
    color: var(--danger) !important;
}

.card.bg-warning.bg-opacity-10 .h3.text-warning {
    color: var(--warning) !important;
}

.card.bg-info.bg-opacity-10 .h3.text-info {
    color: var(--info) !important;
}

/* Dark mode - use brighter versions for visibility */
body.dark-mode .card.bg-primary.bg-opacity-10 .h3.text-primary {
    color: #a5b4fc !important;
}

body.dark-mode .card.bg-success.bg-opacity-10 .h3.text-success {
    color: #4ade80 !important;
}

body.dark-mode .card.bg-danger.bg-opacity-10 .h3.text-danger {
    color: #f87171 !important;
}

body.dark-mode .card.bg-warning.bg-opacity-10 .h3.text-warning {
    color: #fbbf24 !important;
}

body.dark-mode .card.bg-info.bg-opacity-10 .h3.text-info {
    color: #60a5fa !important;
}

/* ========================================
   SOURCE/DESTINATION BOX FIXES
   ======================================== */

/* Fix source location box brightness */
.bg-light.rounded,
.bg-light.rounded-3 {
    background-color: var(--bg-elevated) !important;
}

body.dark-mode .bg-light.rounded,
body.dark-mode .bg-light.rounded-3 {
    background-color: var(--bg-elevated) !important;
}

/* ========================================
   CABLEMAN SOURCE/DESTINATION BOX FIXES
   ======================================== */

/* Source box (bg-primary bg-opacity-10) */
.card.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.08) !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.12) !important;
    border: 1px solid rgba(var(--primary-rgb), 0.25) !important;
}

/* Destination box (bg-secondary bg-opacity-10) */
.card.bg-secondary.bg-opacity-10 {
    background-color: rgba(100, 116, 139, 0.08) !important;
}

body.dark-mode .card.bg-secondary.bg-opacity-10 {
    background-color: rgba(100, 116, 139, 0.15) !important;
    border: 1px solid rgba(100, 116, 139, 0.3) !important;
}

/* Fix text inside source/destination boxes in dark mode */
body.dark-mode .card.bg-primary.bg-opacity-10 .fw-bold,
body.dark-mode .card.bg-primary.bg-opacity-10 h6,
body.dark-mode .card.bg-secondary.bg-opacity-10 .fw-bold,
body.dark-mode .card.bg-secondary.bg-opacity-10 h6 {
    color: var(--text-primary) !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 .form-label,
body.dark-mode .card.bg-secondary.bg-opacity-10 .form-label {
    color: var(--text-secondary) !important;
}

/* ========================================
   INVENTORY SUMMARY BOX FIXES
   ======================================== */

/* Make summary stat cards properly themed in dark mode */
#itemsView .card.shadow {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

#itemsView .card.shadow .text-muted {
    color: var(--text-secondary) !important;
}

#itemsView .card.shadow .h2 {
    color: inherit;
}

/* ========================================
   PRD-005 FIXES
   ======================================== */

/* ----------------------------------------
   PDUMAN.HTML - PDU Details Card Fixes
   ---------------------------------------- */

/* Fix PDU details panel text visibility in dark mode */
body.dark-mode #detailsPanel .card-body .text-muted,
body.dark-mode #detailsPanel .text-secondary {
    color: var(--text-secondary) !important;
}

body.dark-mode #detailsPanel .card-body h6,
body.dark-mode #detailsPanel .card-body .fw-bold,
body.dark-mode #detailsPanel .card-body .fw-semibold,
body.dark-mode #detailsPanel .card-body strong,
body.dark-mode #detailsPanel .card-body p {
    color: var(--text-primary) !important;
}

/* Fix FQDN and IP Address links in PDU details - make them look like links */
/* Use higher specificity to override the fw-semibold rule above */
body.dark-mode #detailsPanel .card-body a[href],
body.dark-mode #detailsPanel a[href] {
    color: #818cf8 !important;
}

body.dark-mode #detailsPanel .card-body a[href]:hover,
body.dark-mode #detailsPanel a[href]:hover {
    color: #a5b4fc !important;
    text-decoration: underline !important;
}

/* Light mode link styling for PDU details */
#detailsPanel .card-body a[href],
#detailsPanel a[href] {
    color: var(--primary) !important;
}

#detailsPanel .card-body a[href]:hover,
#detailsPanel a[href]:hover {
    color: var(--primary-hover) !important;
    text-decoration: underline !important;
}

/* Fix search box magnifying glass icon visibility */
body.dark-mode #pduSearch + svg {
    color: var(--text-secondary) !important;
}

body.dark-mode .form-control + svg,
body.dark-mode .position-absolute svg {
    color: var(--text-muted);
}

/* Fix card header bg-white in dark mode */
body.dark-mode .card-header.bg-white {
    background-color: var(--bg-card) !important;
    color: var(--text-primary);
}

body.dark-mode .card-header.bg-white h5,
body.dark-mode .card-header.bg-white .fw-bold {
    color: var(--text-primary) !important;
}

/* ----------------------------------------
   COOLMAN.HTML - CRAC Chart Card Fixes
   ---------------------------------------- */

/* Fix unit chart stat boxes (Avg, Min, Max) in the small rounded boxes */
body.dark-mode .row.g-2.text-center .bg-light.rounded {
    background-color: var(--bg-elevated) !important;
}

/* Fix the labels (Avg, Min, Max) - make them lighter, not dark gray */
body.dark-mode .row.g-2.text-center .bg-light.rounded .text-muted.small,
body.dark-mode .row.g-2.text-center .bg-light .text-muted {
    color: #94a3b8 !important;
}

/* Fix the temperature values */
body.dark-mode .row.g-2.text-center .bg-light.rounded .fw-bold {
    color: var(--text-primary) !important;
}

/* Coolman stat labels - custom class to avoid CSS specificity issues */
.coolman-stat-label {
    color: #64748b !important;
}

.coolman-stat-label.small,
.small.coolman-stat-label {
    color: #64748b !important;
}

body.dark-mode .coolman-stat-label,
body.dark-mode .coolman-stat-label.small,
body.dark-mode .small.coolman-stat-label {
    color: #94a3b8 !important;
}

/* ----------------------------------------
   CABLEMAN.HTML - Source/Destination Fixes
   ---------------------------------------- */

/* Fix Source Location box - use a more subtle dark background */
body.dark-mode .card.bg-primary.bg-opacity-10 {
    background-color: rgba(99, 102, 241, 0.08) !important;
    border: 1px solid rgba(99, 102, 241, 0.2) !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 h6,
body.dark-mode .card.bg-primary.bg-opacity-10 .fw-bold {
    color: #a5b4fc !important;
}

body.dark-mode .card.bg-primary.bg-opacity-10 .form-label {
    color: var(--text-secondary) !important;
}

/* Destination box matches source styling in dark mode */
body.dark-mode .card.bg-secondary.bg-opacity-10 {
    background-color: rgba(100, 116, 139, 0.08) !important;
    border: 1px solid rgba(100, 116, 139, 0.2) !important;
}

body.dark-mode .card.bg-secondary.bg-opacity-10 h6,
body.dark-mode .card.bg-secondary.bg-opacity-10 .fw-bold {
    color: #94a3b8 !important;
}

/* Fix Saved Runs card - remove purple header, use standard card styling */
body.dark-mode .card-header.bg-primary.bg-opacity-10 {
    background-color: var(--bg-elevated) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

body.dark-mode .card-header.bg-primary.bg-opacity-10 h5,
body.dark-mode .card-header.bg-primary.bg-opacity-10 .fw-bold {
    color: var(--text-primary) !important;
}

/* Light mode - also fix Saved Runs card header to be consistent */
.card-header.bg-primary.bg-opacity-10 {
    background-color: #f8fafc !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.card-header.bg-primary.bg-opacity-10 h5,
.card-header.bg-primary.bg-opacity-10 .fw-bold {
    color: var(--text-primary) !important;
}

/* ----------------------------------------
   INVMAN.HTML - Inventory Card Fixes
   ---------------------------------------- */

/* Fix inventory card wrapper in dark mode */
body.dark-mode .inventory-card-wrapper .card {
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color) !important;
}

body.dark-mode .inventory-card-wrapper .card-body {
    background-color: var(--bg-card) !important;
}

body.dark-mode .inventory-card-wrapper .card-title,
body.dark-mode .inventory-card-wrapper .fw-bold,
body.dark-mode .inventory-card-wrapper .display-4 {
    color: var(--text-primary) !important;
}

body.dark-mode .inventory-card-wrapper .text-muted {
    color: var(--text-secondary) !important;
}

/* Fix category grid cards in invman.html */
body.dark-mode #categoriesGrid .inventory-card-wrapper .card {
    background-color: var(--bg-card) !important;
}

body.dark-mode #categoriesGrid .inventory-card-wrapper .h4 {
    color: var(--text-primary) !important;
}

/* Fix the row text-center stats inside inventory cards */
body.dark-mode .inventory-card-wrapper .row.text-center .h4 {
    color: var(--text-primary) !important;
}

body.dark-mode .inventory-card-wrapper .row.text-center .text-primary {
    color: #818cf8 !important;
}

body.dark-mode .inventory-card-wrapper .row.text-center .text-success {
    color: #4ade80 !important;
}

/* ========================================
   TOAST NOTIFICATIONS (PRD-006)
   ======================================== */

.toast-container .toast {
    min-width: 280px;
    max-width: 400px;
}

.toast .toast-body {
    font-weight: 500;
}

/* Dark mode toast adjustments */
body.dark-mode .toast.text-bg-success { background-color: #166534 !important; }
body.dark-mode .toast.text-bg-danger { background-color: #991b1b !important; }
body.dark-mode .toast.text-bg-warning { background-color: #92400e !important; color: #fff !important; }
body.dark-mode .toast.text-bg-info { background-color: #1e40af !important; }

/* ========================================
   COMPONENT STYLING (PRD-007)
   ======================================== */

/* ----------------------------------------
   MODERN CARD STYLING
   ---------------------------------------- */

/* Base card improvements */
.card {
    border-radius: 12px;
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.card-header {
    background: transparent;
    font-weight: 600;
}

/* Interactive/Clickable cards */
.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body.dark-mode .card-interactive:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

/* ----------------------------------------
   BUTTON MICRO-INTERACTIONS
   ---------------------------------------- */

.btn {
    transition: all 0.15s ease;
    font-weight: 500;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
}

/* Primary button glow effect */
.btn-primary {
    box-shadow: 0 2px 8px rgba(var(--primary-rgb), 0.3);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px rgba(var(--primary-rgb), 0.4);
}

/* Success button glow */
.btn-success {
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-success:hover {
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.4);
}

/* Danger button glow */
.btn-danger {
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
}

/* Icon buttons */
.btn-icon {
    padding: 0.375rem 0.5rem;
    line-height: 1;
}

/* ----------------------------------------
   FORM CONTROL STYLING
   ---------------------------------------- */

.form-control,
.form-select {
    border-radius: 8px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"].form-control:focus,
input[type="search"].form-control:focus,
textarea.form-control:focus {
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), 0 0 10px 2px rgba(147, 51, 234, 0.4) !important;
    border-radius: 0.375rem !important;
}

.form-select:focus {
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25), 0 0 4px 1px rgba(147, 51, 234, 0.15) !important;
}

/* ----------------------------------------
   MODAL STYLING
   ---------------------------------------- */

.modal-content {
    border-radius: 16px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
    padding: 1.25rem 1.5rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
}

/* Optional: Glassmorphism effect */
.modal-glass .modal-content {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.dark-mode .modal-glass .modal-content {
    background: rgba(30, 41, 59, 0.9);
}

/* ----------------------------------------
   TABLE STYLING ENHANCEMENTS
   ---------------------------------------- */

.table {
    --bs-table-bg: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.table tbody tr {
    transition: background-color 0.15s ease;
}

/* ----------------------------------------
   BADGE STYLING ENHANCEMENTS
   ---------------------------------------- */

.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* Status badges with dot indicator */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ----------------------------------------
   LIST GROUP ENHANCEMENTS
   ---------------------------------------- */

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

.list-group-item-action:hover {
    transform: translateX(2px);
}

/* ----------------------------------------
   INPUT GROUP ENHANCEMENTS
   ---------------------------------------- */

.input-group .form-control:focus,
.input-group .form-select:focus {
    z-index: 3;
}

/* ----------------------------------------
   DROPDOWN ENHANCEMENTS
   ---------------------------------------- */

.dropdown-menu {
    border-radius: 10px;
    padding: 0.5rem;
    animation: dropdownFade 0.15s ease;
}

@keyframes dropdownFade {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    transition: background-color 0.15s ease;
}

/* ----------------------------------------
   NAVBAR ENHANCEMENTS
   ---------------------------------------- */

.navbar {
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

/* ----------------------------------------
   PROGRESS BAR ENHANCEMENTS
   ---------------------------------------- */

.progress {
    border-radius: 8px;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.4s ease;
}

/* ========================================
   EMPTY STATES & LOADING (PRD-008)
   ======================================== */

/* ----------------------------------------
   EMPTY STATE COMPONENT
   ---------------------------------------- */

.empty-state {
    padding: 3rem 1rem;
    max-width: 400px;
    margin: 0 auto;
}

.empty-state-icon {
    opacity: 0.6;
    font-size: 4rem;
    line-height: 1;
}

body.dark-mode .empty-state-icon {
    opacity: 0.5;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* ----------------------------------------
   LOADING SKELETON ANIMATION
   ---------------------------------------- */

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-elevated) 25%,
        var(--bg-card) 50%,
        var(--bg-elevated) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes skeleton-pulse {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Skeleton variations */
.skeleton-text {
    height: 1rem;
    width: 80%;
    margin-bottom: 0.5rem;
}

.skeleton-text-sm {
    height: 0.75rem;
    width: 60%;
}

.skeleton-card {
    height: 120px;
    border-radius: 12px;
}

.skeleton-table-row {
    height: 48px;
    margin-bottom: 4px;
}

.skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

/* ----------------------------------------
   LOADING OVERLAY
   ---------------------------------------- */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.loading-overlay.show {
    opacity: 1;
    visibility: visible;
}

body.dark-mode .loading-overlay {
    background: rgba(15, 23, 42, 0.8);
}

/* Spinner */
.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--text-muted);
    font-weight: 500;
}

/* ========================================
   THREE-DOT MENU FIXES (PRD-009)
   ======================================== */

/* Three-dot menu button styling */
.three-dot-menu .btn {
    color: var(--text-secondary);
    opacity: 0.7;
    transition: opacity 0.15s ease, color 0.15s ease;
    border: none;
    background: transparent;
}

.three-dot-menu .btn:hover,
.three-dot-menu .btn:focus {
    color: var(--text-primary);
    opacity: 1;
    background: var(--bg-elevated);
}

.three-dot-menu .btn svg {
    fill: currentColor;
}

/* Dark mode three-dot menu */
body.dark-mode .three-dot-menu .btn {
    color: var(--text-secondary);
}

body.dark-mode .three-dot-menu .btn:hover,
body.dark-mode .three-dot-menu .btn:focus {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

/* Fix dropdown animation jitter - use opacity only for smoother animation */
.three-dot-menu .dropdown-menu {
    animation: dropdownFadeSimple 0.15s ease-out;
    transform-origin: top right;
}

@keyframes dropdownFadeSimple {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   NAVIGATION & LAYOUT OVERHAUL (PRD-010)
   ======================================== */

/* ----------------------------------------
   STICKY HEADER
   ---------------------------------------- */

.header-card {
    position: sticky;
    top: 0;
    z-index: 1030;
    transition: box-shadow 0.2s ease;
}

.header-card.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.dark-mode .header-card.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* ----------------------------------------
   NAVIGATION BAR (New Style)
   ---------------------------------------- */

.racklens-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease, padding 0.2s ease, gap 0.2s ease;
}

.racklens-nav.scrolled {
    box-shadow: var(--shadow-lg);
    border-radius: 0 0 12px 12px;
    top: 0;
    padding: 0 0.5rem;
    gap: 0.2rem;
    overflow: visible;
}

/* Push content down when scrolled to create compact header */
.racklens-nav.scrolled > * {
    transform: translateY(15px);
    transition: transform 0.2s ease;
}

/* Add transition to badges */
.racklens-nav .badge,
.racklens-nav #headerStats {
    transition: opacity 0.2s ease, max-height 0.2s ease;
    max-height: 100px;
    overflow: hidden;
}

/* Add transition to search bar */
.racklens-nav .w-100 {
    transition: opacity 0.2s ease, max-height 0.2s ease;
    max-height: 100px;
    overflow: hidden;
}

/* Hide badges (stats) when scrolled */
.racklens-nav.scrolled .badge,
.racklens-nav.scrolled #headerStats {
    opacity: 0;
    max-height: 0;
    margin: 0;
    padding: 0;
    pointer-events: none;
}

/* Hide search bar row when scrolled */
.racklens-nav.scrolled .w-100,
.racklens-nav.scrolled > .w-100 {
    opacity: 0;
    max-height: 0;
    margin: 0;
    pointer-events: none;
}

/* Logo/Brand link */
.racklens-nav .nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 600;
}

.racklens-nav .nav-brand img {
    height: 32px;
    width: auto;
}

.racklens-nav .nav-brand:hover {
    opacity: 0.8;
}

/* Navigation links - visible on desktop */
.racklens-nav .nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: auto;
}

.racklens-nav .nav-link {
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.racklens-nav .nav-link:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.racklens-nav .nav-link.active {
    background: var(--primary);
    color: white;
}

/* More dropdown */
.racklens-nav .nav-more {
    margin-left: 0.5rem;
}

/* Theme toggle in nav */
.racklens-nav .theme-toggle {
    margin-left: 0.5rem;
}

/* Mobile: hide nav links, show hamburger */
@media (max-width: 768px) {
    .racklens-nav .nav-links {
        display: none;
    }

    .racklens-nav .nav-mobile-toggle {
        display: block;
    }
}

/* Desktop: hide hamburger */
@media (min-width: 769px) {
    .racklens-nav .nav-mobile-toggle {
        display: none;
    }
}

/* ----------------------------------------
   SCROLLABLE HIERARCHY PANELS
   ---------------------------------------- */

/* Sites container - scrollable */
.hierarchy-sites {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Rows container - scrollable */
.hierarchy-rows {
    max-height: 320px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Racks container - scrollable */
.hierarchy-racks {
    max-height: 350px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Units container (cooling) - scrollable */
.hierarchy-units {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Custom scrollbar styling */
.hierarchy-sites::-webkit-scrollbar,
.hierarchy-rows::-webkit-scrollbar,
.hierarchy-racks::-webkit-scrollbar,
.hierarchy-units::-webkit-scrollbar {
    width: 6px;
}

.hierarchy-sites::-webkit-scrollbar-track,
.hierarchy-rows::-webkit-scrollbar-track,
.hierarchy-racks::-webkit-scrollbar-track,
.hierarchy-units::-webkit-scrollbar-track {
    background: var(--bg-elevated);
    border-radius: 3px;
}

.hierarchy-sites::-webkit-scrollbar-thumb,
.hierarchy-rows::-webkit-scrollbar-thumb,
.hierarchy-racks::-webkit-scrollbar-thumb,
.hierarchy-units::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.hierarchy-sites::-webkit-scrollbar-thumb:hover,
.hierarchy-rows::-webkit-scrollbar-thumb:hover,
.hierarchy-racks::-webkit-scrollbar-thumb:hover,
.hierarchy-units::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Firefox scrollbar */
.hierarchy-sites,
.hierarchy-rows,
.hierarchy-racks,
.hierarchy-units {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-elevated);
}

/* Panel section headers */
.hierarchy-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 1;
}

.hierarchy-header h6 {
    margin: 0;
    font-weight: 600;
    color: var(--text-primary);
}

.hierarchy-header .badge {
    font-size: 0.7rem;
}

/* ========================================
   PHOSPHOR ICONS (PRD-013)
   ======================================== */

/* Base icon styling */
.ph {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: currentColor;
    transition: color 0.2s ease;
}

/* Tool card icons - larger, colored */
.tool-card-icon {
    font-size: 2.5rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

/* Explicit background colors for tool card icons */
.tool-card-icon.bg-primary.bg-opacity-10 {
    background-color: rgba(var(--primary-rgb), 0.1) !important;
}
.tool-card-icon.bg-info.bg-opacity-10 {
    background-color: rgba(var(--info-rgb), 0.1) !important;
}
.tool-card-icon.bg-warning.bg-opacity-10 {
    background-color: rgba(var(--warning-rgb), 0.1) !important;
}
.tool-card-icon.bg-danger.bg-opacity-10 {
    background-color: rgba(var(--danger-rgb), 0.1) !important;
}
.tool-card-icon.bg-success.bg-opacity-10 {
    background-color: rgba(var(--success-rgb), 0.1) !important;
}
.tool-card-icon.bg-secondary.bg-opacity-10 {
    background-color: rgba(var(--secondary-rgb, 108, 117, 125), 0.1) !important;
}

.tool-card-icon.bg-primary { color: var(--primary) !important; }
.tool-card-icon.bg-info { color: var(--info) !important; }
.tool-card-icon.bg-warning { color: var(--warning) !important; }
.tool-card-icon.bg-danger { color: var(--danger) !important; }
.tool-card-icon.bg-success { color: var(--success) !important; }
.tool-card-icon.bg-secondary { color: var(--text-secondary) !important; }

/* Dark mode - brighter icon colors for better visibility */
body.dark-mode .tool-card-icon.bg-primary { color: #a5b4fc !important; }
body.dark-mode .tool-card-icon.bg-info { color: #67e8f9 !important; }
body.dark-mode .tool-card-icon.bg-warning { color: #fcd34d !important; }
body.dark-mode .tool-card-icon.bg-danger { color: #fca5a5 !important; }
body.dark-mode .tool-card-icon.bg-success { color: #86efac !important; }

/* Empty state icons */
.empty-state .ph {
    font-size: 4rem;
    opacity: 0.6;
    color: var(--text-secondary);
}

body.dark-mode .empty-state .ph {
    opacity: 0.5;
}

/* Large display icons (used in empty states, lock screens, etc.) */
.display-1 .ph,
.display-2 .ph,
.display-3 .ph,
.display-4 .ph {
    color: var(--text-secondary);
}

body.dark-mode .display-1 .ph,
body.dark-mode .display-2 .ph,
body.dark-mode .display-3 .ph,
body.dark-mode .display-4 .ph {
    color: #94a3b8;
    opacity: 0.8;
}

/* Text-muted display icons - ensure visibility in both modes */
.display-1.text-muted .ph,
.display-2.text-muted .ph,
.display-3.text-muted .ph,
.display-4.text-muted .ph {
    color: inherit;
}

body.dark-mode .display-1.text-muted,
body.dark-mode .display-2.text-muted,
body.dark-mode .display-3.text-muted,
body.dark-mode .display-4.text-muted {
    color: #94a3b8 !important;
}

/* Text-muted icons should be visible in dark mode */
body.dark-mode .text-muted .ph,
body.dark-mode .text-secondary .ph {
    color: inherit;
}

/* Icon color utilities */
.icon-primary { color: var(--primary) !important; }
.icon-success { color: var(--success) !important; }
.icon-danger { color: var(--danger) !important; }
.icon-warning { color: var(--warning) !important; }
.icon-info { color: var(--info) !important; }

/* ========================================
   ENTRANCE ANIMATIONS (PRD-015)
   ======================================== */

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

.animate-fade-in-up {
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
}

/* Staggered delays for sequential animation */
.animate-delay-1 { animation-delay: 0.1s; }
.animate-delay-2 { animation-delay: 0.2s; }
.animate-delay-3 { animation-delay: 0.3s; }
.animate-delay-4 { animation-delay: 0.4s; }
.animate-delay-5 { animation-delay: 0.5s; }
.animate-delay-6 { animation-delay: 0.6s; }

/* Respect user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .animate-fade-in-up {
        animation: none;
        opacity: 1;
        transform: none;
    }
}
.icon-muted { color: var(--text-muted) !important; }

/* Icon size utilities */
.icon-sm { font-size: 1rem; }
.icon-md { font-size: 1.5rem; }
.icon-lg { font-size: 2rem; }
.icon-xl { font-size: 3rem; }
.icon-2xl { font-size: 4rem; }

/* Theme toggle icons */
.theme-toggle .ph {
    font-size: 1.25rem;
}

/* Cable Pathway icons - improved visibility */
.pathway-option .ph {
    color: var(--primary);
    opacity: 0.7;
    transition: opacity 0.2s ease, color 0.2s ease;
}

.pathway-option:hover .ph {
    opacity: 1;
}

.pathway-option.selected .ph {
    color: var(--primary);
    opacity: 1;
}

body.dark-mode .pathway-option .ph {
    color: var(--primary-light, #6ea8fe);
    opacity: 0.85;
}

body.dark-mode .pathway-option.selected .ph {
    color: var(--primary-light, #6ea8fe);
    opacity: 1;
}

/* ========================================
   PRD-029: Enhanced Focus Indicators
   WCAG 2.1 AA Compliant
   ======================================== */

/* Global focus-visible styling */
*:focus-visible {
    outline: 2px solid var(--bs-primary) !important;
    outline-offset: 2px !important;
    border-radius: 0.25rem;
}

/* Dark mode focus indicators */
body.dark-mode *:focus-visible {
    outline-color: var(--primary-light, #6ea8fe) !important;
}

/* Focus indicators for buttons */
.btn:focus-visible {
    outline: 2px solid var(--bs-primary) !important;
    outline-offset: 2px !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

body.dark-mode .btn:focus-visible {
    outline-color: var(--primary-light, #6ea8fe) !important;
    box-shadow: 0 0 0 0.25rem rgba(110, 168, 254, 0.25) !important;
}

/* Focus indicators for text inputs - Brighter purple glow */
input[type="text"]:focus-visible,
input[type="search"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="number"]:focus-visible,
input[type="url"]:focus-visible,
input[type="tel"]:focus-visible,
textarea.form-control:focus-visible {
    border-color: rgba(147, 51, 234, 0.3) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.5), 0 0 10px 2px rgba(147, 51, 234, 0.4) !important;
    border-radius: 0.375rem !important;
}

body.dark-mode input[type="text"]:focus-visible,
body.dark-mode input[type="search"]:focus-visible,
body.dark-mode input[type="email"]:focus-visible,
body.dark-mode input[type="password"]:focus-visible,
body.dark-mode input[type="number"]:focus-visible,
body.dark-mode input[type="url"]:focus-visible,
body.dark-mode input[type="tel"]:focus-visible,
body.dark-mode textarea.form-control:focus-visible {
    border-color: rgba(192, 132, 252, 0.4) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(192, 132, 252, 0.6), 0 0 10px 2px rgba(192, 132, 252, 0.5) !important;
    border-radius: 0.375rem !important;
}

/* Focus indicators for selects - Softer glow */
.form-select:focus-visible,
select:focus-visible {
    border-color: rgba(147, 51, 234, 0.3) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25), 0 0 4px 1px rgba(147, 51, 234, 0.15) !important;
}

body.dark-mode .form-select:focus-visible,
body.dark-mode select:focus-visible {
    border-color: rgba(192, 132, 252, 0.4) !important;
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.3), 0 0 4px 1px rgba(192, 132, 252, 0.2) !important;
}

/* Focus indicators for links - Softer glow */
a:focus-visible {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.25), 0 0 4px 1px rgba(147, 51, 234, 0.15) !important;
    border-radius: 0.25rem;
}

body.dark-mode a:focus-visible {
    box-shadow: 0 0 0 2px rgba(192, 132, 252, 0.3), 0 0 4px 1px rgba(192, 132, 252, 0.2) !important;
}

/* ========================================
   PRD-029: Sortable Table Styles
   ======================================== */

/* Sortable table headers */
.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color 0.15s ease;
}

.sortable:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

body.dark-mode .sortable:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* Sort indicator icons */
.sort-icon {
    opacity: 0.3;
    margin-left: 0.5rem;
    font-size: 0.875rem;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.sortable:hover .sort-icon {
    opacity: 0.6;
}

/* Active sort state */
.sortable.sort-asc .sort-icon {
    opacity: 1;
    transform: rotate(0deg);
}

.sortable.sort-desc .sort-icon {
    opacity: 1;
    transform: rotate(180deg);
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .sort-icon {
        transition: none;
    }
    
    .sortable.sort-desc .sort-icon {
        transform: none;
    }
}

/* ========================================
   PRD-029: Entrance Animations
   ======================================== */

/* Base animation class */
.animate-in {
    animation: fadeInUp 0.5s ease-out;
}

/* Staggered animation delays */
.animate-in-delay-1 {
    animation: fadeInUp 0.5s 0.1s ease-out both;
}

.animate-in-delay-2 {
    animation: fadeInUp 0.5s 0.2s ease-out both;
}

.animate-in-delay-3 {
    animation: fadeInUp 0.5s 0.3s ease-out both;
}

/* Respect reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .animate-in,
    .animate-in-delay-1,
    .animate-in-delay-2,
    .animate-in-delay-3 {
        animation: none;
    }
}

/* ========================================
   PRD-031: Sticky Table Headers (Tier 2)
   ======================================== */

/* Sticky table headers - stay visible on scroll */
.table-sticky-header thead th {
    position: sticky;
    top: 0;
    background-color: var(--bg-elevated);
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

body.dark-mode .table-sticky-header thead th {
    background-color: var(--bg-elevated);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Account for navbar height - adjust top position if needed */
.table-sticky-header thead th {
    top: 0;
}

/* When inside a scrollable container */
.table-responsive .table-sticky-header thead th {
    position: sticky;
    top: 0;
}

/* Disable sticky on mobile to prevent layout issues */
@media (max-width: 768px) {
    .table-sticky-header thead th {
        position: static;
    }
}

/* ========================================
   PRD-031: Search Result Highlighting
   ======================================== */

/* Highlighted search terms */
.search-highlight {
    background-color: rgba(var(--accent-rgb), 0.3);
    padding: 0.1em 0.2em;
    border-radius: 3px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

body.dark-mode .search-highlight {
    background-color: rgba(var(--accent-rgb), 0.4);
    color: var(--text-primary);
}

/* Pulsing animation for newly highlighted results */
@keyframes highlightPulse {
    0%, 100% {
        background-color: rgba(var(--accent-rgb), 0.3);
    }
    50% {
        background-color: rgba(var(--accent-rgb), 0.5);
    }
}

.search-highlight.pulse {
    animation: highlightPulse 1s ease-in-out;
}

/* ========================================
   PRD-031: Mobile Touch Targets
   ======================================== */

/* Ensure minimum touch target size on mobile (44x44px) */
@media (max-width: 768px) {
    /* Buttons */
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 1rem;
    }

    .btn-sm {
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }

    /* Icon buttons */
    .btn-icon,
    .theme-toggle,
    .three-dot-menu .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem;
    }

    /* Links in navigation */
    .nav-link {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    /* Dropdown items */
    .dropdown-item {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    /* Form controls */
    .form-control,
    .form-select {
        min-height: 44px;
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Checkboxes and radios */
    .form-check-input {
        min-width: 24px;
        min-height: 24px;
    }

    /* Badge buttons/clickable badges */
    .badge.btn,
    .badge[onclick],
    .badge[data-bs-toggle] {
        min-height: 32px;
        padding: 0.5rem 0.75rem;
    }

    /* Table action buttons */
    .table .btn {
        min-height: 40px;
        min-width: 40px;
    }

    /* List group items */
    .list-group-item-action {
        min-height: 44px;
        padding: 0.75rem 1rem;
    }

    /* Add spacing between touch targets */
    .btn-group .btn {
        margin: 0 4px;
    }

    .btn-toolbar .btn {
        margin: 4px;
    }
}

/* ========================================
   PRD-031: Enhanced Empty States
   ======================================== */

/* Quick action buttons in empty states */
.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.empty-state-actions .btn {
    min-width: 120px;
}

/* Mobile: stack empty state buttons */
@media (max-width: 576px) {
    .empty-state-actions {
        flex-direction: column;
        align-items: center;
    }

    .empty-state-actions .btn {
        width: 100%;
        max-width: 280px;
    }
}
