@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;600&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f7fb;
  color: #495057;
  font-size: 0.8125rem;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: #0c3368;
  color: white;
  padding: 0 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 40, 100, 0.15);
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

header h1 {
  font-size: 1rem;
  font-weight: 500;
}

.header-divider {
  width: 1px;
  height: 18px;
  background: rgba(255,255,255,0.3);
}

header p {
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Header Tabs */
.header-tabs {
  display: flex;
  gap: 0.25rem;
  height: 100%;
  align-items: center;
}

.header-tabs .tab {
  padding: 0.375rem 0.875rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  border-radius: 4px;
  transition: all 0.15s ease;
}

.header-tabs .tab:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.header-tabs .tab.active {
  background: rgba(255,255,255,0.2);
  color: white;
}

/* Header User */
.header-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-user span {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.8);
}

.logout-btn {
  padding: 0.25rem 0.625rem;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  color: white;
  font-size: 0.6875rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.25);
}

/* Users Layout */
.users-layout {
  padding: 1rem;
  height: 100%;
  overflow: auto;
}

.users-panel {
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 1rem;
}

.users-panel .content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0;
}

.users-panel .section-title {
  font-size: 1rem;
  font-weight: 500;
  color: #495057;
  margin: 0;
}

/* App Container */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid #e5e9f0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
}

.sidebar.collapsed {
  width: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title {
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6c757d;
}

.sidebar-toggle {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: #6c757d;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle:hover {
  background: #f5f7fb;
  color: #495057;
}

/* Sidebar expand button (shown when sidebar collapsed) */
.sidebar-expand {
  display: none;
  background: none;
  border: none;
  padding: 0.375rem;
  cursor: pointer;
  color: #6c757d;
  border-radius: 4px;
  align-items: center;
  justify-content: center;
}

.sidebar-expand:hover {
  background: #f5f7fb;
  color: #495057;
}

.sidebar.collapsed ~ .main-content .sidebar-expand {
  display: flex;
}

/* Category List */
.category-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.375rem;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.625rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.1s ease;
  margin-bottom: 1px;
}

.category-item:hover {
  background: #f5f7fb;
}

.category-item.active {
  background: #e8eef8;
  color: #0c3368;
}

.category-item.active .category-name {
  font-weight: 500;
}

.category-name {
  font-size: 0.75rem;
  color: #495057;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-item.active .category-name {
  color: #0c3368;
}

.category-count {
  font-size: 0.65rem;
  color: #6c757d;
  background: #f0f2f5;
  padding: 0.0625rem 0.3125rem;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

.category-item.active .category-count {
  background: #0c3368;
  color: white;
}

/* Category hierarchy */
.category-item.level-1 { padding-left: 1.25rem; }
.category-item.level-2 { padding-left: 2rem; }
.category-item.level-3 { padding-left: 2.75rem; }

/* Main Content */
.main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Tab Content */
.tab-content {
  display: none;
  flex: 1;
  overflow: hidden;
  flex-direction: column;
}

.tab-content.active {
  display: flex;
}

/* Content Header */
.content-header {
  padding: 0.5rem 0.75rem;
  background: white;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-shrink: 0;
}

.content-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.item-count {
  font-size: 0.75rem;
  color: #6c757d;
}

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  max-width: 320px;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 0.625rem;
  color: #9ca3af;
  pointer-events: none;
}

.search-bar input {
  flex: 1;
  padding: 0.375rem 0.625rem 0.375rem 2rem;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: #f8f9fc;
}

.search-bar input:focus {
  outline: none;
  border-color: #467fcf;
  box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.1);
  background: white;
}

/* Table Container */
.table-container {
  flex: 1;
  overflow: auto;
  background: white;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table th {
  background: #f8f9fc;
  border-bottom: 1px solid #e5e9f0;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #6c757d;
  white-space: nowrap;
}

.data-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}

.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s ease;
}

.data-table tbody tr:hover {
  background: #f8f9fc;
}

.data-table tbody tr.selected {
  background: #e8eef8;
}

.data-table tbody tr.selected td {
  border-bottom-color: #d0ddf0;
}

/* Column widths */
.col-title { min-width: 250px; }
.col-part { width: 120px; }
.col-category { width: 180px; }
.col-location { width: 120px; }
.col-stock { width: 70px; text-align: center; }

.data-table td.col-stock {
  text-align: center;
  font-weight: 500;
}

/* Stock title cell */
.stock-title {
  font-weight: 500;
  color: #1a1a2e;
}

.stock-alt-title {
  font-size: 0.7rem;
  color: #6c757d;
  margin-top: 2px;
}

/* Prefix badge */
.prefix-badge {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: #0c3368;
  color: white;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  padding: 0.375rem 0.75rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: #0c3368;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #316cbe;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5a6268;
}

/* Stock Browser Layout */
.stock-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  overflow: hidden;
}

.stock-list-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stock-detail-panel {
  background: white;
  border-left: 1px solid #e5e9f0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.detail-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-shrink: 0;
}

.detail-title-section {
  min-width: 0;
  flex: 1;
}

.detail-header h3 {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a2e;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-subtitle {
  font-size: 0.7rem;
  color: #6c757d;
  margin: 0.125rem 0 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
}

/* Asset list in detail panel */
.asset-list {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.625rem;
  background: #f8f9fc;
  border: 1px solid #e5e9f0;
  border-radius: 4px;
  font-size: 0.8125rem;
}

.asset-barcode {
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
  color: #0c3368;
}

.asset-status {
  font-size: 0.65rem;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  text-transform: uppercase;
  font-weight: 500;
}

.asset-status.status-0 { background: #e8f5e9; color: #2e7d32; }
.asset-status.status-1 { background: #fff3e0; color: #ef6c00; }
.asset-status.status-2 { background: #ffebee; color: #c62828; }
.asset-status.status-3 { background: #e3f2fd; color: #1565c0; }
.asset-status.status-4 { background: #fce4ec; color: #ad1457; }
.asset-status.status-5 { background: #f5f5f5; color: #616161; }
.asset-status.status-erased { background: #e0e0e0; color: #9e9e9e; }

/* Erased asset styling */
.asset-item.asset-erased {
  opacity: 0.6;
  background: #f0f0f0;
  border-color: #d0d0d0;
}

.asset-item.asset-erased .asset-barcode {
  color: #9e9e9e;
  text-decoration: line-through;
}

/* Show erased toggle */
.show-erased-toggle {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  color: #6c757d;
  cursor: pointer;
  white-space: nowrap;
}

.show-erased-toggle input[type="checkbox"] {
  accent-color: #6c757d;
  width: 12px;
  height: 12px;
}

.no-assets {
  text-align: center;
  padding: 2rem 1rem;
  color: #6c757d;
  font-size: 0.8125rem;
}

.detail-actions {
  display: flex;
  gap: 0.375rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.modal-header {
  padding: 0.875rem 1rem;
  border-bottom: 1px solid #e5e9f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #6c757d;
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: #1a1a2e;
}

.modal-body {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid #e5e9f0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Print labels list */
.print-labels-list {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid #e5e9f0;
  border-radius: 4px;
  padding: 0.5rem;
}

.print-label-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 0.5rem;
  font-size: 0.8125rem;
  border-radius: 3px;
}

.print-label-item:hover {
  background: #f8f9fc;
}

.print-label-item input[type="checkbox"] {
  accent-color: #0c3368;
}

.print-label-item .barcode {
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
}

/* Label select actions */
.label-select-actions {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.label-select-actions .divider {
  color: #ccc;
  font-size: 0.7rem;
}

.btn-link {
  background: none;
  border: none;
  color: #467fcf;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}

.btn-link:hover {
  text-decoration: underline;
  color: #316cbe;
}

/* Print status */
#print-status {
  margin-bottom: 1rem;
}

#print-status:empty {
  display: none;
}

#print-status.error {
  background: #ffebee;
  color: #c62828;
  padding: 0.625rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}

#print-status.success {
  background: #e8f5e9;
  color: #2e7d32;
  padding: 0.625rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}

#print-status.info {
  background: #e3f2fd;
  color: #1565c0;
  padding: 0.625rem;
  border-radius: 4px;
  font-size: 0.8125rem;
}

/* Form select */
.form-select {
  width: 100%;
  padding: 0.375rem 0.625rem;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  background: white;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: #467fcf;
  box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.1);
}

/* Print button on asset items */
.asset-item .print-btn {
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: #6c757d;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-item .print-btn:hover {
  background: #e5e9f0;
  color: #0c3368;
}

/* Generator Layout */
.generator-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  overflow: hidden;
}

.generator-form {
  padding: 1rem;
  background: white;
  border-right: 1px solid #e5e9f0;
  overflow-y: auto;
}

.section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 0.875rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 500;
  font-size: 0.75rem;
  color: #495057;
}

.form-group input[type="text"],
.form-group input[type="number"] {
  width: 100%;
  padding: 0.375rem 0.625rem;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #467fcf;
  box-shadow: 0 0 0 2px rgba(70, 127, 207, 0.1);
}

.form-group small {
  display: block;
  color: #6c757d;
  margin-top: 0.1875rem;
  font-size: 0.6875rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 80px;
  gap: 0.75rem;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  cursor: pointer;
  font-weight: 400;
  font-size: 0.75rem;
}

.checkbox-group input[type="checkbox"] {
  accent-color: #0c3368;
  width: 14px;
  height: 14px;
}

.button-group {
  display: flex;
  gap: 0.375rem;
  margin-top: 1rem;
}

/* Selected item display */
.selected-item {
  padding: 0.5rem 0.625rem;
  background: #f8f9fc;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  font-size: 0.8125rem;
  min-height: 50px;
  display: flex;
  align-items: center;
}

.selected-item .placeholder {
  color: #9ca3af;
  font-size: 0.75rem;
}

.selected-item.has-item {
  border-color: #0c3368;
  background: #f0f4fc;
}

/* Preview Panel */
.preview-panel {
  padding: 1rem;
  overflow-y: auto;
  background: #f8f9fc;
}

.barcode-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.barcode-item {
  padding: 0.375rem 0.625rem;
  background: white;
  border: 1px solid #dde2eb;
  border-radius: 4px;
  font-family: 'Roboto Mono', monospace;
  font-size: 0.8125rem;
  color: #495057;
}

.barcode-item.created {
  background: #e8f5e9;
  border-color: #c8e6c9;
  color: #2e7d32;
}

.barcode-item.error {
  background: #ffebee;
  border-color: #ffcdd2;
  color: #c62828;
}

.placeholder-text {
  color: #9ca3af;
  font-size: 0.8125rem;
  padding: 1rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.625rem 0.875rem;
  background: #1a1a2e;
  color: white;
  border-radius: 4px;
  font-size: 0.8125rem;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.2s ease;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* Loading */
.loading {
  text-align: center;
  padding: 2rem;
  color: #6c757d;
}

/* Scrollbar styling */
.category-list::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.generator-form::-webkit-scrollbar,
.preview-panel::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.category-list::-webkit-scrollbar-track,
.table-container::-webkit-scrollbar-track,
.generator-form::-webkit-scrollbar-track,
.preview-panel::-webkit-scrollbar-track {
  background: transparent;
}

.category-list::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.generator-form::-webkit-scrollbar-thumb,
.preview-panel::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.category-list::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover,
.generator-form::-webkit-scrollbar-thumb:hover,
.preview-panel::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

/* Responsive */
@media (max-width: 1024px) {
  .generator-layout {
    grid-template-columns: 1fr;
  }
  .generator-form {
    border-right: none;
    border-bottom: 1px solid #e5e9f0;
  }
  .stock-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .stock-detail-panel {
    border-left: none;
    border-top: 1px solid #e5e9f0;
    max-height: 250px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    left: 0;
    top: 48px;
    bottom: 0;
    z-index: 50;
    box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  }
  .sidebar.collapsed { width: 0; }
  header { padding: 0 0.5rem; }
  .header-content p, .header-divider { display: none; }
  .header-tabs .tab { padding: 0.375rem 0.5rem; font-size: 0.6875rem; }
  .form-row { grid-template-columns: 1fr; }
}

/* Generator Assets List */
.generator-assets {
  margin-top: 1rem;
  border-top: 1px solid #e5e9f0;
  padding-top: 1rem;
}

.generator-assets-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
}

.generator-asset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.375rem 0.5rem;
  background: #f8f9fc;
  border: 1px solid #e5e9f0;
  border-radius: 4px;
  font-size: 0.75rem;
}

.generator-asset-item .asset-barcode {
  font-family: 'Roboto Mono', monospace;
  font-weight: 500;
  color: #0c3368;
  font-size: 0.75rem;
}

.generator-asset-item .asset-status {
  font-size: 0.6rem;
  padding: 0.0625rem 0.25rem;
}
