/**
 * HRZ OPS - Components
 * Reusable UI components (buttons, cards, badges, etc)
 * Version: 2.0
 */

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  outline: none;
  transition: all var(--transition-fast);
  user-select: none;
}

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

/* Button Variants */
.btn-primary {
  background: var(--emerald);
  color: #000;
  border-color: var(--emerald);
}

.btn-primary:hover:not(:disabled) {
  background: var(--emerald-hover);
  border-color: var(--emerald-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
  background: var(--bg-tertiary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

[data-theme="light"] .btn-ghost:hover:not(:disabled) {
  background: rgba(0, 0, 0, 0.03);
}

.btn-danger {
  background: var(--rose);
  color: #fff;
  border-color: var(--rose);
}

.btn-danger:hover:not(:disabled) {
  background: var(--rose-hover);
  border-color: var(--rose-hover);
}

/* Button Sizes */
.btn-sm {
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

.btn-md {
  padding: 8px 16px;
  font-size: var(--font-size-sm);
}

.btn-lg {
  padding: 12px 24px;
  font-size: var(--font-size-base);
}

/* ===== CARDS ===== */
.card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .card {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
}

[data-theme="light"] .card:hover {
  box-shadow: var(--shadow-md);
  background: var(--bg-secondary);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
}

.card-footer {
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Glass Card Variant */
.glass-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

[data-theme="light"] .glass-card {
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--emerald);
}

.badge-info {
  background: rgba(56, 189, 248, 0.15);
  color: var(--sky);
}

.badge-warning {
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
}

.badge-error {
  background: rgba(251, 113, 133, 0.15);
  color: var(--rose);
}

.badge-neutral {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-tertiary);
}

/* ===== INPUTS ===== */
.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  transition: all var(--transition-fast);
}

.input:hover {
  border-color: var(--border-strong);
}

.input:focus {
  border-color: var(--emerald);
  background: var(--bg-secondary);
}

.input::placeholder {
  color: var(--text-tertiary);
}

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

/* Input Group */
.input-group {
  margin-bottom: var(--space-4);
}

.input-label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.input-help {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
}

/* ===== SELECT ===== */
.select {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  font-family: var(--font-family);
  outline: none;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.select:hover {
  border-color: var(--border-strong);
}

.select:focus {
  border-color: var(--emerald);
}

/* ===== CHECKBOX & RADIO ===== */
.checkbox,
.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  user-select: none;
}

.checkbox input[type="checkbox"],
.radio input[type="radio"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* ===== TABLES ===== */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.table thead {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-default);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--font-weight-semibold);
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] .table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--emerald);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

/* ===== ALERTS ===== */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border-left: 3px solid;
  display: flex;
  align-items: start;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
}

.alert-success {
  background: rgba(52, 211, 153, 0.1);
  border-color: var(--emerald);
  color: var(--emerald);
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border-color: var(--sky);
  color: var(--sky);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.1);
  border-color: var(--amber);
  color: var(--amber);
}

.alert-error {
  background: rgba(251, 113, 133, 0.1);
  border-color: var(--rose);
  color: var(--rose);
}

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

.tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: var(--font-size-xs);
  border-radius: var(--radius-md);
  white-space: nowrap;
  z-index: var(--z-dropdown);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

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

/* ===== DIVIDER ===== */
.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-4) 0;
}

.divider-vertical {
  width: 1px;
  height: 100%;
  background: var(--border-subtle);
  margin: 0 var(--space-4);
}

/* ===== AVATAR ===== */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-sm);
}

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

.avatar-sm { width: 24px; height: 24px; font-size: var(--font-size-xs); }
.avatar-md { width: 32px; height: 32px; font-size: var(--font-size-sm); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--font-size-base); }

/* ===== SKELETON LOADER ===== */
.skeleton {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

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

@keyframes skeleton-loading {
  to { left: 100%; }
}

.skeleton-text {
  height: 12px;
  margin-bottom: var(--space-2);
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: var(--space-3);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
