/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-family-sans);
  font-weight: 600;
  font-size: 1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  text-align: center;
  outline: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-white);
  box-shadow: 0 4px 6px rgba(236, 84, 12, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(236, 84, 12, 0.3);
}

.btn-block {
  width: 100%;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-main);
}

.form-label.required::after {
  content: " *";
  color: var(--color-danger);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: rgba(0, 0, 0, 0.5); /* Deep dark background */
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-white);
  font-family: var(--font-family-sans);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(244, 148, 4, 0.2);
  background-color: rgba(0, 0, 0, 0.7);
}

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

/* Alerts */
.alert {
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideInDown 0.3s ease-out;
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border: 1px solid var(--color-danger);
  color: #fca5a5;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border: 1px solid var(--color-success);
  color: #6ee7b7;
}

.alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border: 1px solid #f59e0b;
  color: #fcd34d;
}

/* Light Theme Alert Overrides */
[data-theme="light"] .alert-warning {
  background-color: rgba(245, 158, 11, 0.15);
  border-color: #d97706;
  color: #92400e;
}

[data-theme="light"] .alert-danger {
  background-color: rgba(239, 68, 68, 0.12);
  border-color: #dc2626;
  color: #991b1b;
}

[data-theme="light"] .alert-success {
  background-color: rgba(16, 185, 129, 0.12);
  border-color: #059669;
  color: #065f46;
}

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

.hidden {
  display: none !important;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--color-surface);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition-normal);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1rem;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.btn-close:hover {
  color: var(--color-danger);
}

.modal-footer {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

.btn-secondary {
  background: var(--color-surface-light);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover {
  background: var(--color-border);
}

.btn-tiny {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
}

.modal-section {
  margin-bottom: 1.5rem;
}

.modal-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.modal-section-title {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
}

.modal-info-box {
  background-color: var(--color-bg-secondary);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.modal-history-box {
  background-color: var(--color-bg-secondary);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  max-height: 150px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
}

.modal-history-list {
  list-style-type: none;
  padding-left: 0;
  margin: 0;
}

/* Fullscreen Modals */
.fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.fullscreen-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.fullscreen-content {
  background: var(--color-surface);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  width: 95%;
  height: 95%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.fullscreen-overlay.active .fullscreen-content {
  transform: scale(1);
}

.fullscreen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--color-border);
  background: rgba(0, 0, 0, 0.2);
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.fullscreen-title {
  margin: 0;
  font-size: 1.25rem;
}

.fullscreen-body {
  padding: 2rem;
  flex-grow: 1;
  overflow-y: auto;
}

.fullscreen-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--color-border);
  background: rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Tabs & Flex Table Containers */
.tabs-container {
  flex-shrink: 0;
}

.tab-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* Data Tables */
.table-container {
  flex-grow: 1;
  overflow-x: auto;
  overflow-y: auto;
  min-height: 0;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--glass-bg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th, .data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-surface);
  box-shadow: inset 0 -1px 0 var(--color-border);
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

[data-theme="light"] .form-control {
  background-color: var(--color-surface);
  color: var(--color-text-main);
}

.badge {
  display: inline-block;
  padding: 0.25em 0.6em;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
}
.badge-success { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.badge-warning { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge-primary { background: rgba(236, 84, 12, 0.2); color: var(--color-primary); }

/* Pagination Controls */
.pagination-controls {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  background: var(--color-bg-secondary, transparent);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: 0.75rem;
}

.pagination-controls select {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-main);
}

.pagination-controls .page-info {
  margin: 0 1rem;
  color: var(--color-text-muted);
}

/* Generic Form Inputs & Selects */
.form-input {
  background-color: var(--color-surface);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-family: var(--font-family-sans);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 2px rgba(244, 148, 4, 0.2);
}

.form-input option,
.pagination-controls select option {
  background-color: var(--color-surface);
  color: var(--color-text-main);
}

/* Search Bar */
.search-bar-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
  max-width: 340px;
}

.search-bar-icon {
  position: absolute;
  left: 0.75rem;
  color: var(--color-text-muted);
  pointer-events: none;
  display: flex;
  align-items: center;
}

.search-bar-input {
  width: 100%;
  padding: 0.45rem 2rem 0.45rem 2.25rem;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background-color: var(--color-surface);
  color: var(--color-text-main);
  transition: all var(--transition-fast);
}

.search-bar-input:focus {
  outline: none;
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 2px rgba(244, 148, 4, 0.2);
}

.search-bar-input::placeholder {
  color: var(--color-text-muted);
}

.search-bar-clear {
  position: absolute;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  display: none;
}

.search-bar-clear:hover {
  color: var(--color-danger);
  background: rgba(239, 68, 68, 0.1);
}

/* Sortable Table Headers */
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.data-table th.sortable:hover {
  background: var(--color-surface-light, var(--color-surface));
  color: var(--color-text-main);
}

.sort-indicator {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 0.7rem;
  opacity: 0.4;
  transition: opacity 0.15s ease, color 0.15s ease;
}

.data-table th.sortable.sort-asc .sort-indicator,
.data-table th.sortable.sort-desc .sort-indicator {
  opacity: 1;
  color: var(--color-secondary);
}

/* Searchable Select Dropdown */
.searchable-select-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 150px;
}

.searchable-select-wrapper.compact {
  width: auto;
  min-width: 165px;
}

.searchable-select-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background-color: var(--color-surface);
  color: var(--color-text-main);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.searchable-select-wrapper.compact .searchable-select-trigger {
  padding: 0.22rem 0.5rem;
  font-size: 0.75rem;
}

.searchable-select-trigger:hover {
  border-color: var(--color-secondary);
}

.searchable-select-trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.searchable-select-arrow {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  transition: transform 0.15s ease;
}

.searchable-select-wrapper.open .searchable-select-arrow {
  transform: rotate(180deg);
}

.searchable-select-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 200px;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.5));
  z-index: 1050;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.searchable-select-wrapper.open .searchable-select-dropdown {
  display: flex;
}

.searchable-select-search-box {
  padding: 0.4rem;
  border-bottom: 1px solid var(--color-border);
  background: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .searchable-select-search-box {
  background: rgba(0, 0, 0, 0.03);
}

.searchable-select-search-input {
  width: 100%;
  padding: 0.35rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 5px;
  background-color: var(--color-surface);
  color: var(--color-text-main);
}

.searchable-select-search-input:focus {
  outline: none;
  border-color: var(--color-secondary);
}

.searchable-select-options {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.searchable-select-option {
  padding: 0.45rem 0.75rem;
  font-size: 0.82rem;
  color: var(--color-text-main);
  cursor: pointer;
  transition: background-color 0.1s ease;
}

.searchable-select-option:hover,
.searchable-select-option.highlighted {
  background-color: rgba(244, 148, 4, 0.15);
}

.searchable-select-option.selected {
  background-color: rgba(236, 84, 12, 0.22);
  font-weight: 600;
  color: var(--color-secondary);
}

.searchable-select-empty {
  padding: 0.6rem 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  text-align: center;
}


