/**
 * EDI-WH Custom Theme Styles
 * Official EDI Logo Palette Integration:
 * - EDI Vibrant Coral Red: #e52e3d
 * - EDI Deep Corporate Navy: #16387c
 * - EDI Navy Hover: #1e40af
 */

:root {
  --edi-red: #e52e3d;
  --edi-red-hover: #c81e2b;
  --edi-navy: #16387c;
  --edi-navy-hover: #1e40af;
}

/* Primary Button Styling */
.btn-primary {
  background-color: var(--edi-navy) !important;
  border-color: var(--edi-navy) !important;
  color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-color: var(--edi-navy-hover) !important;
  border-color: var(--edi-navy-hover) !important;
}

/* Danger Button Styling */
.btn-danger {
  background-color: var(--edi-red) !important;
  border-color: var(--edi-red) !important;
  color: #ffffff !important;
}

.btn-danger:hover, .btn-danger:focus, .btn-danger:active {
  background-color: var(--edi-red-hover) !important;
  border-color: var(--edi-red-hover) !important;
}

/* Outline Primary Button Styling */
.btn-outline-primary {
  color: var(--edi-navy) !important;
  border-color: var(--edi-navy) !important;
}

.btn-outline-primary:hover {
  background-color: var(--edi-navy) !important;
  color: #ffffff !important;
}

/* Override Sidebar Brand Colors */
.sidebar .sidebar-header .sidebar-brand {
  color: #e4e4e7 !important;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar .sidebar-header .sidebar-brand span {
  color: var(--edi-red) !important; /* EDI Red */
}

/* Custom Navigation Icons and Accent Hover States */
.sidebar .sidebar-body .nav .nav-item.active .nav-link,
.sidebar .sidebar-body .nav .nav-item:hover .nav-link {
  color: var(--edi-red) !important;
}

.sidebar .sidebar-body .nav .nav-item.active .nav-link .link-icon,
.sidebar .sidebar-body .nav .nav-item:hover .nav-link .link-icon {
  color: var(--edi-red) !important;
}

/* Logo Sizing in Sidebar Header */
.sidebar-logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.sidebar-logo-img {
  height: 28px;
  max-width: 100%;
  object-fit: contain;
}

/* Glassmorphism Card Effects */
.card-glass {
  background: rgba(18, 18, 26, 0.7) !important;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all 0.3s ease;
}

.card-glass:hover {
  border-color: rgba(229, 46, 61, 0.25) !important;
  box-shadow: 0 8px 32px 0 rgba(229, 46, 61, 0.08);
}

/* Validation badges */
.badge-pending {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 8px;
  font-weight: 500;
}

.badge-validated {
  background-color: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 4px 8px;
  font-weight: 500;
}

.badge-rejected {
  background-color: rgba(229, 46, 61, 0.15);
  color: var(--edi-red);
  border: 1px solid rgba(229, 46, 61, 0.3);
  padding: 4px 8px;
  font-weight: 500;
}

.badge-available-yes {
  background-color: rgba(74, 222, 128, 0.15);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
  padding: 3px 6px;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.badge-available-no {
  background-color: rgba(229, 46, 61, 0.15);
  color: var(--edi-red);
  border: 1px solid rgba(229, 46, 61, 0.3);
  padding: 3px 6px;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.row-no-availability {
  opacity: 0.65;
  background-color: rgba(229, 46, 61, 0.03) !important;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.row-no-availability:hover {
  opacity: 0.85;
  background-color: rgba(229, 46, 61, 0.08) !important;
}

/* Inline Editable Cell Layouts */
.editable-cell {
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s ease;
  min-width: 60px;
  min-height: 22px;
}

.editable-cell:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.editable-cell:hover::after {
  content: '✎';
  position: absolute;
  right: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: #71717a;
}

.cell-editing {
  padding: 0 !important;
  border: 1px solid #f59e0b !important;
  background-color: rgba(245, 158, 11, 0.05) !important;
}

.cell-editing input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: #e4e4e7;
  padding: 6px 12px;
  outline: none;
}

.cell-changed {
  background-color: rgba(245, 158, 11, 0.1) !important;
  border-bottom: 2px solid #f59e0b !important;
}

/* Dropzone styling adjustments for dark mode */
.dropzone {
  background: rgba(18, 18, 26, 0.5) !important;
  border: 2px dashed rgba(255, 255, 255, 0.1) !important;
  border-radius: 8px !important;
  color: #71717a !important;
  transition: all 0.3s ease;
}

.dropzone:hover, .dropzone.dz-drag-hover {
  border-color: var(--edi-red) !important;
  background: rgba(229, 46, 61, 0.08) !important;
  box-shadow: 0 0 15px rgba(229, 46, 61, 0.2);
}

/* Audit Log Table Event Type Badges */
.badge-event {
  background: rgba(22, 56, 124, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(22, 56, 124, 0.4);
  padding: 4px 8px;
}

/* Source Link Buttons */
.btn-source-link {
  color: #3b82f6;
  text-decoration: none;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-source-link:hover {
  color: #60a5fa;
  text-decoration: underline;
}

/* Dynamic Page Transition Loader */
#page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0c0d16;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.5s ease;
}

.loader-glow {
  width: 80px;
  height: 80px;
  border: 4px solid rgba(230, 57, 70, 0.1);
  border-left-color: #e63946;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Light Mode Overrides (Demo 1 Compatibility)
   ========================================================================== */

/* Card Glass Override */
body.light-theme .card-glass {
  background: rgba(255, 255, 255, 0.8) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.05);
}

body.light-theme .card-glass:hover {
  border-color: rgba(230, 57, 70, 0.3) !important;
  box-shadow: 0 8px 32px 0 rgba(230, 57, 70, 0.05);
}

/* Inline Grid Editable Cells overrides */
body.light-theme .editable-cell:hover {
  background-color: rgba(0, 0, 0, 0.04);
}

body.light-theme .editable-cell:hover::after {
  color: #71717a;
}

body.light-theme .cell-editing {
  background-color: rgba(245, 158, 11, 0.05) !important;
  border-color: #f59e0b !important;
}

body.light-theme .cell-editing input {
  color: #111827 !important; /* Dark gray text for light mode input editing */
}

body.light-theme .cell-changed {
  background-color: rgba(245, 158, 11, 0.07) !important;
}

/* File Upload Dropzone overrides */
body.light-theme .dropzone {
  background: rgba(0, 0, 0, 0.01) !important;
  border: 2px dashed rgba(0, 0, 0, 0.12) !important;
  color: #4b5563 !important;
}

body.light-theme .dropzone:hover {
  background: rgba(230, 57, 70, 0.02) !important;
  border-color: #e63946 !important;
}

/* Telemetry Ingestion Pool and progress cards */
body.light-theme .progress {
  background-color: rgba(0, 0, 0, 0.05) !important;
}

/* Page loader override */
body.light-theme #page-loader {
  background: #f9fafb; /* Light background loading screen */
}

body.light-theme .loader-glow {
  border-color: rgba(230, 57, 70, 0.1);
  border-left-color: #e63946;
}

/* Footer layout border adjustment */
body.light-theme footer.footer {
  border-top-color: rgba(0, 0, 0, 0.08) !important;
}

/* Subtext/Meta details label overrides */
body.light-theme .text-muted {
  color: #6b7280 !important;
}

/* ==========================================================================
   UI/UX Enhancement Styles
   ========================================================================== */

/* 1. Global Smooth Theme Transition */
body, .card, .sidebar, .navbar, .footer, .form-control, .form-select, td, th {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

/* 2. Cursor pointer utility */
.cursor-pointer {
  cursor: pointer;
}

/* 3. Glowing border-pulse animation for active job card */
@keyframes border-pulse {
  0% {
    border-color: rgba(245, 158, 11, 0.4) !important;
    box-shadow: 0 4px 20px 0 rgba(245, 158, 11, 0.1) !important;
  }
  50% {
    border-color: rgba(245, 158, 11, 1.0) !important;
    box-shadow: 0 4px 20px 0 rgba(245, 158, 11, 0.3) !important;
  }
  100% {
    border-color: rgba(245, 158, 11, 0.4) !important;
    box-shadow: 0 4px 20px 0 rgba(245, 158, 11, 0.1) !important;
  }
}

.card-glass.border-warning {
  animation: border-pulse 2s infinite ease-in-out !important;
}

/* 4. Light Mode general overrides for inputs and layouts */
body.light-theme .bg-dark {
  background-color: #ffffff !important;
  color: #1f2937 !important;
}

body.light-theme .border-secondary {
  border-color: #e2e8f0 !important;
}

body.light-theme .text-white {
  color: #0f172a !important;
}

body.light-theme .bg-dark-card {
  background-color: #f8fafc !important;
}

body.light-theme .table-hover tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02) !important;
}

body.light-theme .table th, body.light-theme .table td {
  border-color: #e2e8f0 !important;
}

/* ==========================================================================
   Header Brand Title Styling (Red EDI + Navy Gateway Pill)
   ========================================================================== */
.brand-edi-badge {
  background: var(--edi-red) !important;
  color: #ffffff !important;
  font-weight: 800 !important;
  padding: 4px 10px !important;
  border-top-left-radius: 5px !important;
  border-bottom-left-radius: 5px !important;
  border-top-right-radius: 0px !important;
  border-bottom-right-radius: 0px !important;
  letter-spacing: 0.5px !important;
  font-size: 13px !important;
  display: inline-block !important;
  line-height: 1.2 !important;
}

.brand-gateway-badge {
  background: var(--edi-navy) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  padding: 4px 12px !important;
  border-top-right-radius: 5px !important;
  border-bottom-right-radius: 5px !important;
  border-top-left-radius: 0px !important;
  border-bottom-left-radius: 0px !important;
  letter-spacing: 0.5px !important;
  font-size: 13px !important;
  display: inline-block !important;
  line-height: 1.2 !important;
}

/* ==========================================================================
   Authentication & Authorization Styles
   ========================================================================== */

/* Login Page Overlay */
.login-page {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #0c0f17; /* Dark background default */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 99999;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(22, 28, 45, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 12px;
  padding: 40px 30px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo {
  height: 48px;
  margin-bottom: 15px;
}

.login-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.login-field {
  margin-bottom: 20px;
}

.login-field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #8a99ad;
  margin-bottom: 8px;
  font-weight: 600;
}

.login-input-wrap {
  position: relative;
}

.login-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: #8a99ad;
}

.login-input {
  width: 100%;
  padding: 12px 16px 12px 42px;
  background: rgba(10, 14, 23, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  border-radius: 6px;
  color: #ffffff !important;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input:focus {
  outline: none;
  border-color: var(--edi-red) !important;
  box-shadow: 0 0 0 3px rgba(229, 46, 61, 0.15) !important;
}

.login-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 20px;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--edi-red);
  border: none;
  border-radius: 6px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s, transform 0.1s;
}

.login-btn:hover {
  background: #d62231;
}

.login-btn:active {
  transform: scale(0.98);
}

.login-footer {
  text-align: center;
  margin-top: 30px;
  font-size: 11px;
  color: #8a99ad;
}

/* Light Theme overrides for Login screen if needed, but we keep it dark/premium by default */
body.light-theme .login-page {
  background: #f3f4f6;
}

body.light-theme .login-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

body.light-theme .login-input {
  background: #ffffff !important;
  border: 1px solid #d1d5db !important;
  color: #1f2937 !important;
}

body.light-theme .login-input:focus {
  border-color: var(--edi-red) !important;
}

body.light-theme .login-field label {
  color: #4b5563;
}

/* User Profile Navbar Element */
.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(229, 46, 61, 0.1);
  border: 1px solid rgba(229, 46, 61, 0.2);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
}

.user-avatar-icon {
  width: 14px;
  height: 14px;
  color: var(--edi-red);
}

.nav-item.dropdown:hover .user-avatar-sm {
  background: rgba(229, 46, 61, 0.18);
  border-color: rgba(229, 46, 61, 0.35);
}

/* Status Badges */
.bg-success-light {
  background-color: rgba(16, 185, 129, 0.12) !important;
}

.bg-danger-light {
  background-color: rgba(239, 68, 68, 0.12) !important;
}

/* Dark mode overrides for navbar profile menu items */
body.light-theme #user-dropdown-menu {
  background-color: #ffffff !important;
  border-color: #e5e7eb !important;
}

body.light-theme #user-dropdown-menu .dropdown-item {
  color: #374151 !important;
}

body.light-theme #user-dropdown-menu .dropdown-item:hover {
  background-color: #f3f4f6 !important;
}

body.light-theme #user-dropdown-menu .dropdown-item-text {
  color: #1f2937 !important;
}

/* Custom Checkboxes for permission matrix */
.perm-cb.form-check-input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

/* Unchecked dark mode */
.perm-cb.form-check-input:not(:checked) {
  background-color: #12121a !important;
  border: 1px solid #3f3f46 !important;
}

/* Unchecked light mode */
body.light-theme .perm-cb.form-check-input:not(:checked) {
  background-color: #ffffff !important;
  border-color: #ced4da !important;
}

body.light-theme .perm-cb.form-check-input:not(:checked):hover {
  border-color: #adb5bd !important;
}

/* Checked state (both themes) */
.perm-cb.form-check-input:checked {
  background-color: var(--edi-red) !important;
  border-color: var(--edi-red) !important;
}

/* QA Queue Checkbox styling for Dark & Light modes */
.qa-job-checkbox.form-check-input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  background-color: rgba(18, 18, 26, 0.8) !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  transition: all 0.15s ease;
}

body.light-theme .qa-job-checkbox.form-check-input {
  background-color: #ffffff !important;
  border: 1px solid #cbd5e1 !important;
}

.qa-job-checkbox.form-check-input:checked,
body.light-theme .qa-job-checkbox.form-check-input:checked {
  background-color: var(--edi-red) !important;
  border-color: var(--edi-red) !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e") !important;
}

/* Explorer Table Word Wrap Overrides to Prevent Horizontal Scrolling */
#bonds-explorer-table {
  width: 100% !important;
  table-layout: auto !important;
}

#bonds-explorer-table th, 
#bonds-explorer-table td {
  white-space: normal !important;
  word-break: break-word !important;
  vertical-align: middle;
}

#bonds-explorer-table td[data-field="security_desc_1"] {
  max-width: 260px;
  min-width: 150px;
}

#bonds-explorer-table td[data-field="issuer_name"] {
  max-width: 200px;
  min-width: 120px;
}

#bonds-explorer-table .badge {
  white-space: nowrap !important; /* Keep status badges on a single line */
}

/* Custom 1600px Breakpoint Responsive Utilities */
.d-1600-table-cell {
  display: none !important;
}

@media (min-width: 1600px) {
  .d-1600-table-cell {
    display: table-cell !important;
  }
}

/* Fixed 97vw x 97vh Fullscreen SweetAlert Verification Console Modal */
.swal2-almost-fullscreen {
  width: 97vw !important;
  max-width: 97vw !important;
  height: 97vh !important;
  min-height: 97vh !important;
  max-height: 97vh !important;
  padding: 1.25rem 1.5rem !important;
  background: #11131f !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8) !important;
  border-radius: 12px !important;
  display: flex !important;
  flex-direction: column !important;
}

body.light-theme .swal2-almost-fullscreen {
  background: #ffffff !important;
  border-color: #e5e7eb !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
}

.swal2-almost-fullscreen .swal2-title {
  text-align: left !important;
  font-size: 1.25rem !important;
  padding: 0 0 0.75rem 0 !important;
  margin: 0 !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  color: #ffffff !important;
}

body.light-theme .swal2-almost-fullscreen .swal2-title {
  color: #111827 !important;
  border-bottom-color: #e5e7eb !important;
}

.swal2-almost-fullscreen .swal2-html-container {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  margin: 0.75rem 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
}

.swal2-almost-fullscreen .swal2-html-container > div {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

.modal-verification-container {
  flex: 1 1 auto !important;
  max-height: none !important;
  height: 100% !important;
  overflow-y: auto !important;
  border-radius: 6px;
}

.swal2-almost-fullscreen .swal2-actions {
  display: flex !important;
  width: 100% !important;
  justify-content: flex-start !important;
  gap: 10px !important;
  margin-top: auto !important;
  padding-top: 0.75rem !important;
  border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
}

body.light-theme .swal2-almost-fullscreen .swal2-actions {
  border-top-color: #e5e7eb !important;
}

/* Push Cancel button to the far RIGHT, Download & SFTP stay on the LEFT */
.swal2-almost-fullscreen .swal2-cancel {
  margin-left: auto !important;
}

/* Fix Dropdown Menu clipping & z-index inside Batch QA table while allowing dedicated scroll containers */
.card-glass .table-responsive:not(.scroll-table-container) {
  overflow: visible !important;
}

/* Custom 4-row scrollable table container for ISIN preview */
.scroll-table-container {
  max-height: 175px !important;
  overflow-y: auto !important;
  overflow-x: auto !important;
  display: block !important;
}

#batch-qa-table .dropdown-menu {
  z-index: 1060 !important;
}

/* Focused Row Highlight Disabled */
tr.table-row-focused {
  background-color: transparent !important;
  outline: none !important;
}

