/* ========================================
   UI Components Bundle - Common UI Elements
   Generated: 2025-08-16
   Part of modular CSS architecture
   ======================================== */

/* ========================================
   LOADING & SPINNERS
   ======================================== */
.loading {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-subtle);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

.spinner-lg {
  width: 60px;
  height: 60px;
  border-width: 6px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn.loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay:not(.active) {
  display: none !important;
}

/* ========================================
   ALERTS & NOTIFICATIONS
   ======================================== */
.alert {
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  position: relative;
}

.alert-success {
  color: #0f5132;
  background-color: #d1e7dd;
  border-color: #badbcc;
}

.alert-error,
.alert-danger {
  color: #842029;
  background-color: #f8d7da;
  border-color: #f5c2c7;
}

.alert-warning {
  color: #664d03;
  background-color: #fff3cd;
  border-color: #ffecb5;
}

.alert-info {
  color: #055160;
  background-color: #cff4fc;
  border-color: #b6effb;
}

.alert-dismissible {
  padding-right: 3rem;
}

.alert-dismissible .btn-close {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 2;
  padding: 1.25rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.5;
}

.alert-dismissible .btn-close:hover {
  opacity: 0.75;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin-bottom: 0.5rem;
  padding: 0.75rem 1rem;
  pointer-events: auto;
  min-width: 250px;
  max-width: 350px;
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left: 4px solid var(--success-color);
}

.toast.error {
  border-left: 4px solid var(--error);
}

.toast.warning {
  border-left: 4px solid var(--warning-color);
}

.toast.info {
  border-left: 4px solid var(--info-color);
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: nowrap;
  vertical-align: baseline;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-primary {
  color: var(--text-on-accent);
  background-color: var(--primary-color);
}

.badge-secondary {
  color: var(--text-on-accent);
  background-color: var(--secondary-color);
}

.badge-success {
  color: white;
  background-color: var(--success-color);
}

.badge-danger {
  color: white;
  background-color: var(--error);
}

.badge-warning {
  color: var(--text-primary);
  background-color: var(--warning-color);
}

.badge-info {
  color: white;
  background-color: var(--info-color);
}

.badge-light {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.badge-dark {
  color: white;
  background-color: var(--text-primary);
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  margin: 2rem 0;
}

.pagination-item {
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-base);
}

.pagination-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary-color);
}

.pagination-item.active {
  background: var(--primary-color);
  color: var(--text-on-accent);
  border-color: var(--primary-color);
}

.pagination-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.pagination-prev,
.pagination-next {
  padding: 0.5rem 1rem;
}

.page-info {
  margin: 0 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ========================================
   TABLES
   ======================================== */
.table {
  width: 100%;
  margin-bottom: 1rem;
  background-color: var(--bg-surface);
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.75rem;
  vertical-align: top;
  border-top: 1px solid var(--border-subtle);
}

.table thead th {
  vertical-align: bottom;
  border-bottom: 2px solid var(--border-default);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.table tbody + tbody {
  border-top: 2px solid var(--border-default);
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: var(--bg-hover);
}

.table-hover tbody tr:hover {
  background-color: var(--bg-hover);
}

.table-bordered {
  border: 1px solid var(--border-default);
}

.table-bordered th,
.table-bordered td {
  border: 1px solid var(--border-default);
}

.table-responsive {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border-default);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-base);
  margin-bottom: -2px;
  font-weight: 500;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
  background: var(--bg-surface);
}

.tab-content {
  padding: 1.5rem 0;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ========================================
   TOOLTIPS
   ======================================== */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip-text {
  visibility: hidden;
  background-color: var(--text-primary);
  color: var(--bg-surface);
  text-align: center;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: var(--text-primary) transparent transparent transparent;
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ========================================
   PROGRESS BARS
   ======================================== */
.progress {
  height: 1.25rem;
  overflow: hidden;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

.progress-bar {
  height: 100%;
  background-color: var(--primary-color);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  transition: width 0.6s ease;
}

.progress-bar.success {
  background-color: var(--success-color);
}

.progress-bar.warning {
  background-color: var(--warning-color);
}

.progress-bar.danger {
  background-color: var(--error);
}

.progress-bar-striped {
  background-image: linear-gradient(
    45deg,
    rgba(255, 255, 255, .15) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255, 255, 255, .15) 50%,
    rgba(255, 255, 255, .15) 75%,
    transparent 75%,
    transparent
  );
  background-size: 1rem 1rem;
}

.progress-bar-animated {
  animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
  from { background-position: 1rem 0; }
  to { background-position: 0 0; }
}

/* ========================================
   AVATARS
   ======================================== */
.avatar {
  display: inline-block;
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-secondary);
  border: 2px solid var(--border-default);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm {
  width: 32px;
  height: 32px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

.avatar-xl {
  width: 80px;
  height: 80px;
}

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--primary-bg-light);
  font-size: 0.875rem;
}

.avatar-group {
  display: inline-flex;
  align-items: center;
}

.avatar-group .avatar {
  margin-left: -0.5rem;
  border: 2px solid var(--bg-surface);
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

/* ========================================
   BREADCRUMBS
   ======================================== */
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  list-style: none;
  background-color: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-item + .breadcrumb-item {
  padding-left: 0.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  padding-right: 0.5rem;
  color: var(--text-muted);
}

.breadcrumb-item a {
  color: var(--link);
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: var(--text-muted);
}

/* ========================================
   EMPTY STATES
   ======================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.empty-state-message {
  margin-bottom: 1.5rem;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.clearfix::after {
  display: block;
  clear: both;
  content: "";
}

/* ============================================
   Type Selection Buttons - Extracted from main.css
   ============================================ */

.type-grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
}

.type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
}

.type-grid {
        grid-template-columns: repeat(2, 1fr);
    }

.type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1.5rem 1rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.type-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.type-btn.selected {
    background: var(--primary-bg-light);
    border-color: var(--primary-color);
}

.type-btn i {
    font-size: 2rem;
    color: var(--text-muted);
}

.type-btn.selected i {
    color: var(--primary-color);
}

.type-btn span {
    font-size: 0.875rem;
    color: var(--text-color);
}

.document-type-selector {
    margin-bottom: 2rem;
    text-align: center;
}

.document-type-selector h3 {
    margin-bottom: 1.5rem;
    color: var(--text-color);
}
