/* ============================================================
   PRIME LEDGER — components.css

   Standardized component library CSS.
   Additive to shared.css — provides canonical implementations
   of all UI components used across the platform.

   Include this after shared.css in any module that needs
   consistent, reusable component styling.
   ============================================================ */

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: var(--font);
}

.btn-primary {
  background: var(--teal);
  color: white;
}
.btn-primary:hover {
  background: #026a8c;
  box-shadow: 0 0 16px rgba(3, 136, 166, 0.4);
}

.btn-secondary {
  background: transparent;
  color: var(--teal);
  border: 1px solid var(--teal);
}
.btn-secondary:hover {
  background: rgba(3, 136, 166, 0.1);
}

.btn-tertiary {
  background: transparent;
  color: var(--mid);
  border: 1px solid var(--border);
}
.btn-tertiary:hover {
  background: rgba(3, 136, 166, 0.05);
  color: var(--white);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

.btn-lg {
  padding: 1rem 2rem;
  font-size: 1rem;
}

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

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.badge-info {
  background: rgba(3, 136, 166, 0.15);
  color: var(--teal);
}

.badge-neutral {
  background: rgba(139, 139, 139, 0.15);
  color: var(--mid);
}

/* ── CARDS ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin: -1.5rem -1.5rem 0 -1.5rem;
}

.card-header h3 {
  color: var(--teal);
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  margin: 0 -1.5rem -1.5rem -1.5rem;
  background: rgba(3, 136, 166, 0.02);
}

.card-hover:hover {
  border-color: var(--teal);
  box-shadow: 0 0 16px rgba(3, 136, 166, 0.15);
  transition: all 0.3s;
}

/* ── CARD GRID ── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: 1fr;
  }
}

/* ── TABLES ── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  text-align: left;
  padding: 0.75rem;
  background: rgba(3, 136, 166, 0.05);
  border-bottom: 1px solid var(--border);
  color: var(--mid);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--bone);
}

.table tr:hover td {
  background: rgba(3, 136, 166, 0.03);
}

.table-striped tbody tr:nth-child(even) {
  background: rgba(3, 136, 166, 0.02);
}

.table-striped tbody tr:nth-child(even):hover {
  background: rgba(3, 136, 166, 0.05);
}

/* ── TABS ── */
.tabs-container {
  display: flex;
  flex-direction: column;
}

.tabs-nav {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: 0;
}

.tab-btn {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: all 0.3s;
  font-family: var(--font);
}

.tab-btn:hover {
  color: var(--teal);
}

.tab-btn.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

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

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

/* ── FORMS ── */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--white);
  font-size: 0.95rem;
  font-weight: 500;
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--mid);
  font-size: 0.8rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--white);
  font-size: 0.95rem;
  font-family: var(--font);
  transition: all 0.2s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 8px rgba(3, 136, 166, 0.3);
  background: rgba(255, 255, 255, 0.08);
}

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

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-checkbox,
.form-radio {
  margin-right: 0.5rem;
  cursor: pointer;
}

/* ── KPI CARDS ── */
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
}

.kpi-label {
  font-size: 0.75rem;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--teal);
  margin: 0.5rem 0;
}

.kpi-value.success {
  color: #10b981;
}

.kpi-value.warning {
  color: #f59e0b;
}

.kpi-value.danger {
  color: #ef4444;
}

.kpi-sub {
  font-size: 0.8rem;
  color: #9ca3af;
}

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

@media (max-width: 768px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── STATUS INDICATORS ── */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.status-dot.active {
  background: #10b981;
}

.status-dot.pending {
  background: #f59e0b;
}

.status-dot.blocked {
  background: #ef4444;
}

.status-dot.inactive {
  background: #6b7280;
}

.status-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.status-inline span {
  color: var(--white);
  font-size: 0.9rem;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
  flex: 1;
  min-width: 80px;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--teal);
  transition: width 0.4s ease-in-out;
}

.progress-fill.success {
  background: #10b981;
}

.progress-fill.warning {
  background: #f59e0b;
}

.progress-fill.danger {
  background: #ef4444;
}

/* ── TYPOGRAPHY HELPERS ── */
.text-muted {
  color: var(--mid);
}

.text-small {
  font-size: 0.85rem;
}

.text-mono {
  font-family: var(--mono);
}

.text-uppercase {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* ── SPACING UTILITIES ── */
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mt-lg { margin-top: 1.5rem; }
.mt-xl { margin-top: 2rem; }

.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }
.mb-lg { margin-bottom: 1.5rem; }
.mb-xl { margin-bottom: 2rem; }

.p-sm { padding: 0.5rem; }
.p-md { padding: 1rem; }
.p-lg { padding: 1.5rem; }

.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }

/* ── LAYOUT UTILITIES ── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.flex-center {
  justify-content: center;
  align-items: center;
}

.flex-between {
  justify-content: space-between;
  align-items: center;
}

.flex-wrap {
  flex-wrap: wrap;
}

.grid {
  display: grid;
}

.grid-auto {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

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

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

@media (max-width: 768px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* ── DIVIDERS ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.5rem 0;
}

.divider-vertical {
  width: 1px;
  background: var(--border);
  height: 100%;
}

/* ── MODALS / OVERLAYS ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.modal-header h2 {
  margin: 0;
  color: var(--white);
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--mid);
  cursor: pointer;
  font-size: 1.5rem;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--white);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* ── ALERTS / CALLOUTS ── */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  border-left: 4px solid transparent;
  margin-bottom: 1rem;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border-left-color: #10b981;
  color: #10b981;
}

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

.alert-danger {
  background: rgba(239, 68, 68, 0.1);
  border-left-color: #ef4444;
  color: #ef4444;
}

.alert-info {
  background: rgba(3, 136, 166, 0.1);
  border-left-color: var(--teal);
  color: var(--teal);
}

.alert p {
  margin: 0;
  font-size: 0.95rem;
}

/* ── AVATAR ── */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--teal);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
}

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

.avatar-md {
  width: 48px;
  height: 48px;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 1.25rem;
}

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

.tooltip-text {
  visibility: hidden;
  background-color: rgba(0, 0, 0, 0.8);
  color: #fff;
  text-align: center;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  position: absolute;
  z-index: 1;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.8rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.8);
}

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

/* ── SKELETON / LOADING ── */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(3, 136, 166, 0.05) 0%,
    rgba(3, 136, 166, 0.1) 50%,
    rgba(3, 136, 166, 0.05) 100%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton-text {
  height: 1rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.skeleton-card {
  height: 200px;
  border-radius: 8px;
}

/* ── RESPONSIVE UTILITIES ── */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .show-mobile {
    display: none !important;
  }
}

/* ── ACCESSIBILITY ── */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ── FOCUS STATES ── */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ── PRINT STYLES ── */
@media print {
  .no-print {
    display: none !important;
  }

  .card {
    page-break-inside: avoid;
  }
}
