/* Import standardized gray variables */
@import 'variables.css';

/* Bootstrap 5.3 Color Mode Custom Properties */
:root,
[data-bs-theme="light"] {
  /* Core colors - minimized palette */
  --bs-primary: var(--gray-medium);
  --bs-secondary: var(--gray-medium);
  --bs-success: var(--gray-medium);
  --bs-danger: var(--gray-medium);
  --bs-warning: var(--gray-medium);
  --bs-info: var(--gray-medium);
  --bs-body-bg: white;
  --bs-body-color: var(--gray-dark);
  --bs-border-color: var(--gray-light);
  
  /* Component colors */
  --bs-sidebar-bg: var(--gray-light);
  --bs-card-hover-shadow: 0 4px 12px var(--overlay-light);
  --bs-link-color: var(--bs-primary);
  --bs-link-hover-color: var(--gray-dark);
}

[data-bs-theme="dark"] {
  /* Core colors */
  --bs-primary: var(--muted-color);
  --bs-secondary: var(--gray-medium);
  --bs-success: var(--muted-color);
  --bs-danger: var(--muted-color);
  --bs-warning: var(--muted-color);
  --bs-info: var(--muted-color);
  --bs-body-bg: var(--body-bg);
  --bs-body-color: var(--gray-light);
  --bs-border-color: var(--gray-medium);
  
  /* Component colors */
  --bs-sidebar-bg: var(--gray-dark);
  --bs-card-hover-shadow: 0 4px 12px var(--overlay-dark);
  --bs-link-color: var(--bs-primary);
  --bs-link-hover-color: var(--muted-color);
}

/* Base Layout */
.layout-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  position: fixed;
  height: 100vh;
  overflow-y: auto;
  background: var(--bs-sidebar-bg);
  border-right: 1px solid var(--bs-border-color);
  transition: transform 0.3s;
  z-index: 1000;
  scrollbar-width: none;
}

.sidebar::-webkit-scrollbar {
  display: none;
}

.sidebar-collapsed .sidebar {
  transform: translateX(-250px);
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--bs-border-color);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--bs-body-color);
}

.sidebar-brand i {
  margin-right: 0.625rem;
  font-size: 1.5rem;
  color: var(--bs-primary);
}

/* Sidebar Menu */
.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-menu .menu-section {
  padding: 1rem 1.25rem 0.625rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--bs-secondary);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  text-decoration: none;
  color: var(--bs-body-color);
  transition: background-color 0.2s;
}

.sidebar-menu a:hover {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
}

.sidebar-menu a.active {
  background-color: rgba(var(--bs-primary-rgb), 0.15);
  border-left: 3px solid var(--bs-primary);
}

.sidebar-menu i {
  margin-right: 0.625rem;
  width: 1.25rem;
  text-align: center;
}

/* Main Content */
.main-wrapper {
  flex: 1;
  margin-left: 250px;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s;
}

.sidebar-collapsed .main-wrapper {
  margin-left: 0;
}

.top-header {
  padding: 1rem 1.25rem;
  background: var(--bs-body-bg);
  border-bottom: 1px solid var(--bs-border-color);
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
}

/* Theme Toggle - Simplified */
.theme-toggle-group {
  display: inline-flex;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  padding: 2px;
  background: var(--gray-light);
}

[data-bs-theme="dark"] .theme-toggle-group {
  background: var(--gray-dark);
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--bs-secondary);
  cursor: pointer;
  transition: all 0.2s;
  padding: 0;
}

.theme-toggle:hover {
  color: var(--bs-body-color);
  background: var(--overlay-light);
}

[data-bs-theme="dark"] .theme-toggle:hover {
  background: var(--overlay-white);
}

.theme-toggle.active {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] .theme-toggle.active {
  background: var(--hover-bg);
}

/* Monochrome button overrides */
[class*="btn-"]:is(.btn-primary, .btn-secondary, .btn-success, .btn-info, .btn-warning, .btn-danger) {
  --bs-btn-bg: white;
  --bs-btn-border-color: var(--gray-medium);
  --bs-btn-hover-bg: var(--gray-light);
  --bs-btn-hover-border-color: var(--gray-medium);
  --bs-btn-active-bg: var(--gray-light);
  --bs-btn-active-border-color: var(--gray-dark);
  --bs-btn-color: var(--gray-dark);
  --bs-btn-hover-color: var(--gray-dark);
}

[class*="btn-outline-"]:is(.btn-outline-primary, .btn-outline-secondary, .btn-outline-success, .btn-outline-info, .btn-outline-warning, .btn-outline-danger) {
  --bs-btn-color: var(--gray-medium);
  --bs-btn-border-color: var(--gray-medium);
  --bs-btn-hover-bg: var(--gray-medium);
  --bs-btn-hover-border-color: var(--gray-medium);
  --bs-btn-hover-color: white;
  --bs-btn-active-bg: var(--gray-medium);
  --bs-btn-active-border-color: var(--gray-medium);
  --bs-btn-active-color: white;
}

[data-bs-theme="dark"] [class*="btn-"]:is(.btn-primary, .btn-secondary, .btn-success, .btn-info, .btn-warning, .btn-danger) {
  --bs-btn-bg: var(--gray-dark);
  --bs-btn-border-color: var(--muted-color);
  --bs-btn-hover-bg: var(--gray-medium);
  --bs-btn-hover-border-color: var(--muted-color);
  --bs-btn-color: var(--gray-light);
  --bs-btn-hover-color: var(--gray-light);
}

[data-bs-theme="dark"] [class*="btn-outline-"]:is(.btn-outline-primary, .btn-outline-secondary, .btn-outline-success, .btn-outline-info, .btn-outline-warning, .btn-outline-danger) {
  --bs-btn-color: var(--muted-color);
  --bs-btn-border-color: var(--muted-color);
  --bs-btn-hover-bg: var(--muted-color);
  --bs-btn-hover-border-color: var(--muted-color);
  --bs-btn-hover-color: var(--gray-black);
  --bs-btn-active-bg: var(--muted-color);
  --bs-btn-active-border-color: var(--muted-color);
  --bs-btn-active-color: var(--gray-black);
}

/* Monochrome badge overrides */
[class*="badge-"]:is(.badge-primary, .badge-secondary, .badge-success, .badge-info, .badge-warning, .badge-danger),
.bg-primary, .bg-secondary, .bg-success, .bg-info, .bg-warning, .bg-danger {
  background-color: var(--gray-light) !important;
  color: var(--gray-dark) !important;
}

[data-bs-theme="dark"] [class*="badge-"]:is(.badge-primary, .badge-secondary, .badge-success, .badge-info, .badge-warning, .badge-danger),
[data-bs-theme="dark"] :is(.bg-primary, .bg-secondary, .bg-success, .bg-info, .bg-warning, .bg-danger) {
  background-color: var(--gray-dark) !important;
  color: var(--muted-color) !important;
}

/* Form controls override */
.form-check-input:checked {
  background-color: var(--gray-medium);
  border-color: var(--gray-medium);
}

.form-check-input:focus {
  border-color: var(--gray-medium);
  box-shadow: 0 0 0 0.25rem rgba(var(--gray-medium-rgb), 0.25);
}

[data-bs-theme="dark"] .form-check-input:checked {
  background-color: var(--muted-color);
  border-color: var(--muted-color);
}

[data-bs-theme="dark"] .form-check-input:focus {
  border-color: var(--muted-color);
  box-shadow: 0 0 0 0.25rem rgba(var(--muted-color-rgb), 0.25);
}

/* Card Enhancement */
/* Removed all hover effects for cards */

/* Login Page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-light);
}

[data-bs-theme="dark"] .login-page {
  background: var(--body-bg);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 2.5rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1rem var(--overlay-light);
}

/* Header Elements */
.header-left {
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.user-avatar {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-weight: 500;
}

/* Utility Classes */
.sidebar-toggle {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--bs-body-color);
}

.card-icon {
  font-size: 2.5rem;
  color: var(--bs-primary);
  margin-bottom: 1rem;
}

.login-icon {
  font-size: 3rem;
  color: var(--gray-medium);
}

.scrollable-container-sm {
  max-height: 500px;
  overflow-y: auto;
}

.scrollable-container-lg {
  max-height: 600px;
  overflow-y: auto;
}

.main-content-full {
  padding: 2rem 0;
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.inline-block {
  display: inline-block;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-250px);
  }
  
  .sidebar-collapsed .sidebar {
    transform: translateX(0);
  }
  
  .main-wrapper {
    margin-left: 0;
  }
  
  .main-content {
    padding: 1rem;
  }
}

/* Smooth transitions after page load */
html[data-bs-theme] * {
  transition: background-color 0.3s, color 0.3s, border-color 0.3s;
}

/* Prevent flash during initial load */
html:not([data-bs-theme]) * {
  transition: none !important;
}

/* Document Viewer Styles */
.document-viewer-container {
  overflow: auto;
  background-color: transparent;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  position: relative;
}

/* Only set min-height for PDF/image viewers */
.document-viewer-container:has(#pdfCanvas),
.document-viewer-container:has(.image-viewer-wrapper) {
  min-height: 400px;
}

.pdf-controls {
  background-color: var(--bs-white);
  padding: 0.5rem;
  border-top: 1px solid var(--bs-border-color);
}

.image-viewer-wrapper {
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.ocr-overlay {
  pointer-events: none;
  z-index: 10;
}

.field-item.highlighted {
  background-color: rgba(var(--bs-primary-rgb), 0.1);
  border-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Notification History Styles */
.notification-history-wrapper {
  position: relative;
  margin-right: 1rem;
}

.notification-bell {
  background: none;
  border: none;
  color: var(--bs-body-color);
  font-size: 1.2rem;
  padding: 0.5rem;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
}

.notification-bell:hover {
  color: var(--bs-primary);
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  background-color: var(--bs-danger);
  color: white;
  font-size: 0.75rem;
  font-weight: bold;
  padding: 0.15rem 0.35rem;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1;
}

.notification-history-panel {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  width: 350px;
  max-height: 500px;
  background-color: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  z-index: 1050;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.notification-history-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--bs-gray-100);
}

.notification-history-header h6 {
  margin: 0;
  font-weight: 600;
}

.clear-history {
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  text-decoration: none;
}

.notification-list {
  overflow-y: auto;
  max-height: 400px;
}

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--bs-border-color);
  display: flex;
  gap: 0.75rem;
  transition: background-color 0.2s;
}

.notification-item:hover {
  background-color: var(--bs-gray-100);
}

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

.notification-icon {
  font-size: 1.25rem;
  width: 1.5rem;
  flex-shrink: 0;
}

.notification-item.notification-info .notification-icon {
  color: var(--bs-info);
}

.notification-item.notification-success .notification-icon {
  color: var(--bs-success);
}

.notification-item.notification-warning .notification-icon {
  color: var(--bs-warning);
}

.notification-item.notification-danger .notification-icon,
.notification-item.notification-error .notification-icon {
  color: var(--bs-danger);
}

.notification-content {
  flex: 1;
  min-width: 0;
}

.notification-message {
  font-size: 0.875rem;
  line-height: 1.4;
  margin-bottom: 0.25rem;
  word-wrap: break-word;
}

.notification-time {
  font-size: 0.75rem;
  color: var(--bs-text-muted);
}

.notification-empty {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--bs-text-muted);
}

.notification-empty i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  opacity: 0.5;
}

.notification-empty p {
  margin: 0;
  font-size: 0.875rem;
}

/* Dark theme adjustments */
[data-bs-theme="dark"] .notification-history-header {
  background-color: var(--bs-dark);
}

[data-bs-theme="dark"] .notification-item:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

/* Table hover styles */
.table-hover {
  --bs-table-hover-bg: #f8f9fa;
}

[data-bs-theme="dark"] .table-hover {
  --bs-table-hover-bg: rgba(255, 255, 255, 0.06);
}

.table-hover > tbody > tr:hover > * {
  --bs-table-bg-state: var(--bs-table-hover-bg) !important;
}

/* Tooltip styles */
[data-bs-theme="light"] {
  --tooltip-bg: var(--gray-light);
  --tooltip-color: var(--gray-dark);
}

[data-bs-theme="dark"] {
  --tooltip-bg: var(--gray-dark);
  --tooltip-color: var(--gray-light);
}

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

/* All tooltip arrows */
.tooltip .tooltip-arrow::before {
  border-color: transparent !important;
}

.tooltip.bs-tooltip-top .tooltip-arrow::before {
  border-top-color: var(--tooltip-bg) !important;
}

.tooltip.bs-tooltip-end .tooltip-arrow::before {
  border-right-color: var(--tooltip-bg) !important;
}

.tooltip.bs-tooltip-bottom .tooltip-arrow::before {
  border-bottom-color: var(--tooltip-bg) !important;
}

.tooltip.bs-tooltip-start .tooltip-arrow::before {
  border-left-color: var(--tooltip-bg) !important;
}

/* Right-side modal styles */
.modal-right-side .modal-dialog {
  position: fixed !important;
  margin: 0 !important;
  width: 400px;
  height: 100%;
  right: 0;
  top: 0;
  transform: none !important;
  max-width: 400px;
}

.modal-right-side .modal-content {
  height: 100%;
  border-radius: 0;
  border: none;
  border-left: 1px solid var(--bs-border-color);
}

.modal-right-side.show .modal-dialog {
  transform: translateX(0);
}

.modal-right-side .modal-body {
  overflow-y: auto;
}

/* Fade in from right animation */
.modal-right-side.fade .modal-dialog {
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .modal-right-side .modal-dialog {
    width: 100%;
    max-width: 100%;
  }
}