/**
 * Component Styles
 * Reusable UI components: buttons, cards, alerts, forms, tables, modals, etc.
 */

/* === ALERTS & FLASH MESSAGES === */

/* Flash Messages Container */
.flash-messages-container {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  z-index: 1030;
  width: 100%;
  pointer-events: none;
}

.flash-messages-container .container {
  pointer-events: auto;
  max-width: 1140px;
  transition: all 0.3s ease;
}

.flash-messages-container-shifted-right .container {
  position: absolute;
  left: 0;
  right: 0;
}

/* Alert Styling */
.alert {
  margin: 10px 0;
  border: none;
  border-radius: var(--border-radius);
  border-left: 4px solid;
  backdrop-filter: blur(10px);
  margin-bottom: 1.5rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  animation: slideInDown 0.3s ease;
}

.alert-success {
  background: rgba(46, 213, 115, 0.1);
  color: var(--accent-success);
  border-left-color: var(--accent-success);
}

.alert-danger {
  background: rgba(255, 71, 87, 0.1);
  color: var(--accent-danger);
  border-left-color: var(--accent-danger);
}

.alert-warning {
  background: rgba(255, 149, 0, 0.1);
  color: var(--accent-warning);
  border-left-color: var(--accent-warning);
}

.alert-info {
  background: rgba(0, 217, 255, 0.1);
  color: var(--accent-primary);
  border-left-color: var(--accent-primary);
}

.fade.show {
  animation: slideDown 0.3s ease-out;
}

@media (max-width: 768px) {
  .flash-messages-container {
    padding: 0 15px;
  }
  .alert {
    margin-top: 10px;
  }
}

/* === CARDS === */

.card {
  background: var(--gradient-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  overflow: hidden;
  color: var(--text-primary);
}

.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.card-header {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 1.5rem;
  color: var(--text-primary);
}

.card-title,
.card-text {
  color: var(--text-primary);
}

/* === BUTTONS === */

.btn {
  border-radius: var(--border-radius);
  font-weight: 500;
  padding: 0.625rem 1.25rem;
  transition: var(--transition-fast);
  border: none;
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: var(--transition-smooth);
}

.btn:hover::before {
  left: 100%;
}

.btn-primary {
  background:
    linear-gradient(
      rgba(0, 0, 0, 0.15),
      rgba(0, 0, 0, 0.15)
    ),
    var(--gradient-primary);
  color: white;
}

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

.btn-danger {
  background: var(--accent-danger);
  color: white;
}

.btn-warning {
  background: var(--accent-warning);
  color: white;
}

.btn-outline-primary,
.btn-outline-info {
  border: 2px solid var(--accent-primary);
  color: var(--accent-primary);
  background: transparent;
}

.btn-outline-primary:hover,
.btn-outline-info:hover {
  background: var(--accent-primary);
  color: white;
}

.btn-block {
  display: block;
  width: 100%;
}

/* === FORMS === */

.form-control,
.form-select {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: var(--border-radius);
  transition: var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  background: var(--bg-secondary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
  color: var(--text-primary);
}

.form-label {
  color: var(--text-secondary);
  font-weight: 500;
}

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

/* OTP Input Styles */
.otp-inputs {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.otp-inputs .form-control {
  height: 4rem;
  font-size: 1.5rem;
  border-radius: 12px;
  text-align: center;
  font-weight: 600;
  margin: 0 0.25rem;
  padding: 0;
  border: 2px solid var(--border-color);
  transition: all 0.2s ease;
}

.otp-inputs .form-control:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
  outline: none;
}

/* === TABLES === */

.table-wrapper {
  background: var(--bg-secondary);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  color: var(--text-primary);
  margin-bottom: 0;
  background: var(--bg-secondary);
  border-radius: var(--border-radius);
  overflow: hidden;
  border-collapse: separate;
  border-spacing: 0;
}

.table > :not(caption) > * > * {
  padding: 1rem;
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
}

.table > tbody {
  vertical-align: middle;
}

.table td {
  color: var(--text-primary);
  border-color: var(--border-color);
  padding: 1rem;
  vertical-align: middle;
}

.table thead th {
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
  padding: 1rem;
}

.table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-fast);
}

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

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --bs-table-accent-bg: var(--bg-secondary);
  color: var(--text-primary);
}

.table-striped > tbody > tr:nth-of-type(even) > * {
  --bs-table-accent-bg: var(--bg-tertiary);
  color: var(--text-primary);
}

.table > :not(:last-child) > :last-child > * {
  border-bottom-color: var(--border-color);
}

/* === MODALS === */

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.modal-body {
  padding: 1rem;
}

.modal-footer {
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}

.modal-title {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.modal-close {
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.05em;
}

.modal-close:hover,
.modal-close:focus,
.modal-close:active,
.modal-close:visited,
.modal-close:link {
  color: var(--accent-primary);
  outline: none;
}

/* === BADGES & STATUS === */

.badge {
  background-color: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.35em 0.65em;
  border-radius: 0.25rem;
  font-size: 0.875em;
}

/* Bootstrap Badge Color Overrides for Better Contrast */
/* These ensure proper text color contrast when using Bootstrap bg-* utility classes */
.badge.bg-primary {
  color: #ffffff !important;
}

.badge.bg-secondary {
  color: #ffffff !important;
}

.badge.bg-success {
  color: #ffffff !important;
}

.badge.bg-danger {
  color: #ffffff !important;
}

.badge.bg-warning {
  color: #000000 !important;
  /* Warning yellow needs dark text for readability */
}

.badge.bg-info {
  color: #ffffff !important;
}

.badge.bg-light {
  color: #000000 !important;
}

.badge.bg-dark {
  color: #ffffff !important;
}

.status-badge {
  padding: 0.375rem 0.75rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-active {
  background: rgba(46, 213, 115, 0.2);
  color: var(--accent-success);
}

.status-pending {
  background: rgba(255, 149, 0, 0.2);
  color: var(--accent-warning);
}

.status-inactive {
  background: rgba(255, 71, 87, 0.2);
  color: var(--accent-danger);
}

/* === TIMELINE === */

.timeline {
  position: relative;
  padding-left: 0;
  margin-bottom: 2rem;
}

/* Vertical line connecting items */
.timeline::before {
  content: '';
  position: absolute;
  left: 1rem;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
  padding-left: 3rem;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-badge {
  position: absolute;
  top: 0;
  left: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.timeline-badge.bg-primary {
  background: var(--accent-primary) !important;
}

.timeline-badge i {
  font-size: 0.875rem;
  color: white;
}

.timeline-content {
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  padding: 1rem;
  border: 1px solid var(--border-color);
}

.timeline-content h6 {
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.timeline-content p {
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.timeline-content small {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* === LIST GROUPS === */

.list-group-item {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-smooth);
  color: var(--text-primary);
}

.list-group-item:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.list-group-item a {
  color: var(--text-primary);
  text-decoration: none;
}

/* === DETAIL VIEW COMPONENTS === */

.detail-section {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.detail-section h3 {
  color: var(--primary);
  margin-bottom: 1.2rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.detail-item {
  margin-bottom: 1rem;
}

.detail-label {
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.detail-value {
  color: var(--text-color);
  word-break: break-word;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}

.badge-list li {
  list-style: none;
}

/* === LOADING STATES === */

.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(0, 217, 255, 0.1), transparent);
  animation: loading-shimmer 2s infinite;
}

/* Monitoring Dashboard - Loading States */
.loading-placeholder {
  color: #6c757d;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
}

.loading-placeholder .spinner-border {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}

/* For larger loading areas */
.loading-placeholder.text-center p {
  margin-top: 0.5rem;
  color: #6c757d;
}
/* Responsive adjustments for loading states */
@media (max-width: 768px) {
  .loading-placeholder {
    font-size: 0.85rem;
  }
  
  .loading-placeholder .spinner-border {
    width: 0.875rem;
    height: 0.875rem;
  }
}

/* System health cards transition */
#system-health-cards .card {
  transition: box-shadow 0.3s ease;
}

#system-health-cards .card:hover {
  box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.1);
}

/* Smooth icon color transitions */
#system-health-cards i {
  transition: color 0.3s ease;
}

@keyframes loading-shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* === THEME TOGGLE BUTTON === */

.theme-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  color: var(--text-primary);
  padding: 0.5rem 0.75rem;
  margin-right: 1rem;
  transition: var(--transition-fast);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  transform: scale(1.05);
}

.theme-toggle i {
  font-size: 1.1rem;
  transition: var(--transition-fast);
}

.theme-toggle:hover i {
  transform: rotate(20deg);
}

/* === PASSPORT VIEWER === */

.passport-container {
  max-width: 90vw;
  margin: 0 auto;
}

.passport-placeholder {
  position: relative;
  width: 100%;
  max-width: 100%;
  max-height: 90vh;
  background: var(--bg-tertiary);
  border: 2px solid var(--border-color);  /* Changed from dashed to solid for visibility */
  border-radius: var(--border-radius);
  overflow: hidden;  /* Changed from visible to hidden to contain image */
  min-height: 400px;
}

.passport-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(248, 249, 250, 0.95);  /* Semi-transparent background for better visibility */
  color: var(--text-muted);
  transition: var(--transition-normal);
  z-index: 1;
  cursor: pointer;  /* Indicate it's clickable */
}

.passport-overlay:hover {
  background: rgba(233, 236, 239, 0.98);
  color: var(--text-primary);
}

.passport-placeholder img {
  width: 100%;
  max-width: 100%;  /* Changed from 90vw to 100% to respect container bounds */
  max-height: 90vh;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: var(--border-radius);
}

.passport-hide-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

