/* ===== ROOT VARIABLES ===== */
:root {
  /* Color Variables */
  --primary-color: #008097;
  --secondary-color: #6c757d;
  --sidebar-color: #343a40;
  --accent-color: #008097;
  --border-color: #e0e0e0;
  --text-color: #212529;
  --light-gray: #f8f9fa;
  --light-bg: #ffffff;
  --medium-gray: #e9ecef;
  --dark-gray: #495057;
  --white: #ffffff;
  --success-color: #28a745;
  --info-color: #17a2b8;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --sidebar-active-bg: rgba(0, 128, 151, 0.7);

  /* Sizing Variables */
  --base-size: 1rem;
  --space-xs: calc(var(--base-size) * 0.5);  /* 0.5rem */
  --space-sm: calc(var(--base-size) * 0.75); /* 0.75rem */
  --space-md: var(--base-size);              /* 1rem */
  --space-lg: calc(var(--base-size) * 1.5);  /* 1.5rem */
  --space-xl: calc(var(--base-size) * 2);    /* 2rem */
  --border-radius: 0.25rem;                  /* 4px */
  --box-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.1);

  /* Layout Variables */
  --sidebar-expanded-width: 15.625rem;       /* 250px */
  --header-height: 4rem;                     /* 64px */
  --transition-speed: 0.3s;
}

/* ===== BASE STYLES ===== */
body {
  background-color: var(--light-bg);
  color: var(--text-color);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
}

/* ===== LAYOUT COMPONENTS ===== */

/* Sidebar */
.sidebar {
  width: var(--sidebar-expanded-width);
  height: 100vh;
  background: var(--sidebar-color);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.hamburger-btn {
  display: none;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-md) var(--space-xs);
  overflow-y: auto;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
}

.sidebar-nav a,
.logout-btn {
  display: flex;
  align-items: center;
  padding: var(--space-sm) var(--space-xs);
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  border-radius: var(--border-radius);
  margin: 0 var(--space-xs) var(--space-xs);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.sidebar-nav a:hover,
.logout-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav a.active {
  background: var(--sidebar-active-bg);
  color: var(--white);
}

.sidebar-nav i,
.logout-btn i {
  min-width: 1.5625rem;
  text-align: center;
  margin-right: var(--space-sm);
  font-size: 1.1rem;
}

.sidebar-footer {
  padding: var(--space-md) var(--space-xs);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.menu-text {
  opacity: 1;
}

/* Header */
.header {
  background-color: var(--light-gray);
  height: var(--header-height);
  position: fixed;
  top: 0;
  left: var(--sidebar-expanded-width);
  right: 0;
  width: calc(100% - var(--sidebar-expanded-width));
  z-index: 1050;
  transition: none;
  display: flex;
  align-items: center;
  padding: 0 var(--space-md);
  box-shadow: 0 0.125rem 0.3125rem rgba(0, 0, 0, 0.1);
  border-bottom: 1px solid var(--border-color);
}

.header-logo {
  width: 9.375rem;
  height: 2.5rem;
}

.header-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* Main Content */
.main-content {
  margin-top: var(--header-height);
  margin-left: var(--sidebar-expanded-width);
  padding: var(--space-md);
  transition: none;
  text-align: left;
  align-items: flex-start;
  justify-content: flex-start;
}

/* ===== CARDS & GRID ===== */
.custom-row {
  display: flex;
  flex-wrap: wrap;
  margin: -0.5rem;
  width: calc(100% + 1rem);
}

.custom-col {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  box-sizing: border-box;
}

.menu-card,
.supplier-card {
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  padding: 1.25rem;
  height: 100%;
  background: var(--white);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.menu-card:hover,
.supplier-card:hover {
  transform: translateY(-0.3125rem);
  box-shadow: 0 0.3125rem 0.9375rem rgba(0, 0, 0, 0.1);
}

.menu-icon {
  width: 3.125rem;
  height: 3.125rem;
  background: rgba(0, 128, 151, 0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.9375rem;
  color: var(--accent-color);
  font-size: 1.5rem;
}

.menu-category {
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 0.9375rem;
  font-size: 1.5rem;
  text-align: center;
}

.supplier-name {
  color: var(--accent-color);
  font-weight: 600;
  margin-bottom: 0.9375rem;
  font-size: 1rem;
  text-align: left;
}

/* ===== BUTTONS & FORM ELEMENTS ===== */
.btn {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--border-radius);
  transition: all 0.3s ease;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background-color: #006e80;
  border-color: #006e80;
}

/* Accent button - needs higher specificity */
.btn.btn-accent {
  background-color: var(--accent-color) !important;
  border-color: var(--accent-color) !important;
  color: var(--white) !important;
}

.btn.btn-accent:hover {
  background-color: #006e80 !important;
  border-color: #006e80 !important;
  color: var(--white) !important;
  transform: translateY(-0.125rem);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
}

/* Outline accent variant */
.btn.btn-outline-accent {
  background-color: transparent !important;
  border-color: var(--accent-color) !important;
  color: var(--accent-color) !important;
}

.btn.btn-outline-accent:hover {
  background-color: var(--accent-color) !important;
  color: var(--white) !important;
}
/* ===== FORM ELEMENTS ===== */
.form-control,
.form-select {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background-color: var(--white);
  color: var(--text-color);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(0, 138, 162, 0.2);
}

/* ONLY target explicitly disabled or readonly elements - FIXED */
.form-control:disabled,
.form-select:disabled,
.form-control[readonly],
.form-select[readonly] {
  background-color: var(--light-gray) !important;
  border-color: var(--medium-gray) !important;
  color: var(--dark-gray) !important;
  cursor: not-allowed;
  opacity: 0.95;
}

/* Remove the problematic :read-only pseudo-class selectors */
/* .form-control:read-only, */
/* .form-select:read-only, */

/* Specific styling for readonly/disabled inputs */
input[readonly].form-control,
textarea[readonly].form-control,
select[readonly].form-control,
input[readonly].form-select,
select[readonly].form-select,
input:disabled.form-control,
textarea:disabled.form-control,
select:disabled.form-control,
input:disabled.form-select,
select:disabled.form-select {
  background-color: var(--light-gray) !important;
  border-color: var(--medium-gray) !important;
  color: var(--dark-gray) !important;
}

/* Fix for disabled select options */
.form-select:disabled {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%236c757d' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
}

/* Ensure normal active elements maintain their styles */
.form-control:not([readonly]):not(:disabled),
.form-select:not([readonly]):not(:disabled) {
  background-color: var(--white);
  color: var(--text-color);
  opacity: 1;
  cursor: auto;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  background-color: transparent !important;
  padding: 0 !important;
  margin-bottom: var(--space-md) !important;
}

.breadcrumb-item {
  color: var(--secondary-color) !important;
}

.breadcrumb-item a {
  color: var(--accent-color) !important;
  text-decoration: none !important;
}

.breadcrumb-item a:hover {
  color: #006e80 !important;
  text-decoration: underline !important;
}

.breadcrumb-item.active {
  color: var(--dark-gray) !important;
}

/* Breadcrumb separator */
.breadcrumb-item + .breadcrumb-item::before {
  color: var(--secondary-color) !important;
  content: "/" !important;
}

/* ===== SEARCH & AUTOCOMPLETE ===== */
.search-container {
  flex: 1;
  min-width: 15.625rem;
  padding: 0.625rem 0;
  border-radius: 0.25rem;
  margin: 0;
  width: 100%;
}

.search-box.input-group {
  width: 100%;
  margin: 0;
  padding: 0;
}

.search-results-dropdown {
  display: none;
  position: absolute;
  width: 100%;
  max-height: 18.75rem;
  overflow-y: auto;
  background: var(--light-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  z-index: 1000;
  margin-top: var(--space-xs);
  padding: var(--space-xs) 0;
}

.search-results-dropdown a {
  display: block;
  padding: var(--space-xs) var(--space-md);
  text-decoration: none;
  transition: background-color var(--transition-speed) ease;
}

.search-results-dropdown a:hover {
  background-color: var(--light-gray);
}

.search-result-item {
  padding: var(--space-sm) 1.25rem;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.search-result-category {
  font-weight: 600;
  margin-right: var(--space-xs);
}

.autocomplete-dropdown {
  position: absolute;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  max-height: 25rem;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  max-width: 24rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  margin-top: 0.125rem;
  margin-left: 1rem;
}

.autocomplete-item {
  padding: 0.75rem 0.9375rem;
  cursor: pointer;
  border-bottom: 1px solid var(--light-gray);
  transition: background-color 0.15s ease-in-out;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: var(--medium-gray);
}

.material-code {
  font-weight: bold;
  color: #0d6efd;
  font-size: 1.1em;
  margin-bottom: 0.25rem;
}

.material-desc {
  font-size: 0.9em;
  color: var(--secondary-color);
  margin-bottom: 0.125rem;
  line-height: 1.4;
}

.language-tag {
  font-size: 0.75em;
  background: var(--secondary-color);
  color: var(--white);
  padding: 0.125rem 0.375rem;
  border-radius: 0.1875rem;
  margin-right: 0.5rem;
  font-weight: 500;
}



/* bom-styles.css */
.material-autocomplete-results {
    position: absolute;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    max-height: 400px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    max-width: 50rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 2px;
}

.autocomplete-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.15s ease-in-out;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #e9ecef;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.material-code {
    font-weight: bold;
    color: #0d6efd;
    font-size: 1.1em;
    margin-bottom: 4px;
}

.material-desc {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 2px;
    line-height: 1.4;
}

.language-tag {
    font-size: 0.75em;
    background: #6c757d;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    margin-right: 8px;
    font-weight: 500;
}

.no-results {
    padding: 12px 15px;
    color: #6c757d;
    font-style: italic;
    text-align: center;
}

/* ===== BOM SPECIFIC STYLES ===== */

/* BOM Autocomplete */
.material-autocomplete-results {
  position: absolute;
  background: var(--white);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  max-height: 25rem;
  overflow-y: auto;
  z-index: 1000;
  display: none;
  max-width: 50rem;
  box-shadow: var(--box-shadow);
  margin-top: var(--space-xs);
}

.autocomplete-item {
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  border-bottom: 1px solid var(--light-gray);
  transition: background-color var(--transition-speed) ease-in-out;
}

.autocomplete-item:hover,
.autocomplete-item.active {
  background-color: var(--medium-gray);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.material-code {
  font-weight: bold;
  color: var(--primary-color);
  font-size: 1.1em;
  margin-bottom: var(--space-xs);
}

.material-desc {
  font-size: 0.9em;
  color: var(--secondary-color);
  margin-bottom: 0.125rem;
  line-height: 1.4;
}

.language-tag {
  font-size: 0.75em;
  background: var(--secondary-color);
  color: var(--white);
  padding: 0.125rem 0.375rem;
  border-radius: 0.1875rem;
  margin-right: var(--space-sm);
  font-weight: 500;
}

.no-results {
  padding: var(--space-sm) var(--space-md);
  color: var(--secondary-color);
  font-style: italic;
  text-align: center;
}

/* BOM Table Styles */
#bomTable {
  font-size: 0.875rem;
  border-collapse: separate;
  border-spacing: 0;
}

#bomTable th {
  background-color: var(--light-gray);
  font-weight: 600;
  padding: var(--space-sm);
  border-bottom: 2px solid var(--border-color);
}

#bomTable td {
  padding: var(--space-sm);
  vertical-align: middle;
}

#bomTable .table-primary {
  background-color: rgba(0, 128, 151, 0.05);
  border-left: 3px solid var(--accent-color);
}

.quantity-input {
  text-align: right;
  font-family: monospace;
}

.remove-row {
  padding: var(--space-xs) var(--space-sm);
  transition: all var(--transition-speed) ease;
}

.remove-row:hover {
  background-color: var(--danger-color);
  border-color: var(--danger-color);
  color: var(--white);
}

/* BOM Form Controls */
.form-control-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.875rem;
}

.item-category-select {
  min-width: 8rem;
}

.material-search-input {
  min-width: 10rem;
}

.material-description-en,
.material-description-zh,
.material-description-de {
  background-color: var(--light-gray);
  font-style: italic;
}

/* ===== BOM ===== */
#bomTableContainer {
    display: none;
}

/* Ensure buttons are properly sized */
#addFirstComponent.btn-sm,
#addMoreRows.btn-sm,
#saveBomBtn.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}





/* ===== MENU ACTIONS ===== */
.menu-actions,
.supplier-actions {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1.25rem;
}

.menu-actions a {
  text-decoration: none;
  text-align: left;
}

.menu-action-gray {
  padding: 0.5rem 0.75rem;
  background: var(--light-gray);
  border-radius: 0.25rem;
  color: var(--text-color);
  text-decoration: none;
  transition: all 0.3s ease;
  text-align: center;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.1);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.menu-action-gray:hover {
  background: var(--accent-color);
  color: var(--white);
  transform: translateY(-0.125rem);
  box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.15);
  text-decoration: none;
  border-color: var(--accent-color);
}

.menu-action-gray:hover i {
  color: var(--white);
  transform: translateX(0.1875rem);
}

/* ===== SUPPLIER SPECIFIC ===== */
.quality-badge {
  position: absolute;
  top: -0.5rem;
  right: -0.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1rem;
  color: var(--white);
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.quality-poor { background: #d74141; }
.quality-average { background: #e9a348; }
.quality-good { background: #388e3c; }
.quality-excellent { background: #1976d2; }
.quality-na { background: #767676; }

.remarks-header {
  cursor: pointer;
  padding: 0.5rem;
  margin: -0.5rem;
  border-radius: 0.25rem;
  transition: background-color 0.2s ease;
}

.remarks-header:hover {
  background-color: var(--light-gray);
}

.remarks-content {
  font-size: 0.9em;
  line-height: 1.4;
}

.toggle-icon {
  transition: transform 0.3s ease;
  font-size: 0.8em;
}

.remarks-header[aria-expanded="true"] .toggle-icon {
  transform: rotate(180deg);
}

/* ===== TABS ===== */
.nav-tabs .nav-link {
  color: var(--text-color) !important;
  background-color: var(--light-gray) !important;
  border-color: var(--border-color) var(--border-color) transparent !important;
  font-weight: 400;
}

.nav-tabs .nav-link:hover {
  color: var(--text-color) !important;
  background-color: var(--medium-gray) !important;
  border-color: var(--accent-color) var(--accent-color) transparent !important;
}

.nav-tabs .nav-link.active {
  color: var(--white) !important;
  background-color: var(--accent-color) !important;
  border-color: var(--accent-color) var(--accent-color) var(--white) !important;
  font-weight: 500;
}

/* Remove the bottom border for active tab since we're using background color */
.nav-tabs .nav-link.active {
  border-bottom: 1px solid var(--accent-color) !important;
}

.nav-tabs .nav-link:focus {
  box-shadow: none !important;
  outline: none !important;
}

.tab-pane {
  padding: 1rem 0;
}

/* ===== UTILITY CLASSES ===== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.text-accent {
  color: var(--accent-color);
}

.required-field::after {
  content: " *";
  color: var(--danger-color);
}

.no-results {
  padding: 0.75rem 0.9375rem;
  color: var(--secondary-color);
  font-style: italic;
  text-align: center;
}

/* ===== LOADING & STATES ===== */
.spinner,
.loading-spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 0.125rem solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--white);
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Mobile */
@media (max-width: 48rem) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-expanded-width);
  }
  
  .sidebar.expanded {
    transform: translateX(0);
    box-shadow: 0.3125rem 0 0.9375rem rgba(0, 0, 0, 0.2);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .header {
    left: 0;
    width: 100%;
  }
  
  .custom-col {
    width: 33.333333%;
  }
}

/* Tablet */
@media (min-width: 37.5rem) {
  .custom-col {
    width: 50%;
  }
}

/* Desktop */
@media (min-width: 75rem) {
  .custom-col {
    width: 33.333333%;
  }
}

/* Large Desktop */
@media (min-width: 93.75rem) {
  .custom-col {
    width: 25%;
  }
}

/* Extra Large Desktop */
@media (min-width: 112.5rem) {
  .custom-col {
    width: 20%;
  }
}

@media (min-width: 131.25rem) {
  .custom-col {
    width: 16.666667%;
  }
}

@media (min-width: 150rem) {
  .custom-col {
    width: 14.285714%;
  }
}

@media (min-width: 168.75rem) {
  .custom-col {
    width: 12.5%;
  }
}

/* ===== GENERAL UTILITIES ===== */
* {
  box-sizing: border-box;
}

.dashboard-project {
  max-width: 75rem;
  margin: 0 auto;
  padding: var(--space-md);
}

.chart-container {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-md);
  margin-bottom: var(--space-lg);
}

.load-more-container {
  display: flex;
  justify-content: center;
  margin-top: 2rem;
  padding: 1rem 0;
  gap: 1rem;
}

.results-controls-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.quantity-selector-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quantity-selector-label {
  font-size: 0.9rem;
  color: var(--secondary-color);
  white-space: nowrap;
}

.quantity-selector {
  padding: 0.375rem 1.5rem 0.375rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  background-color: var(--white);
  color: var(--text-color);
  font-size: 0.9rem;
}