/**
 * CoCLinks Platform — Engine UI System
 * Core UI primitives: Forms, Inputs, Buttons, Alerts & Feedback
 * Loaded globally before styles.css
 */

/* ==========================================================================
   Forms & Input Controls
   ========================================================================== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition-apple);
  outline: none;
}

.form-input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-badge-bg);
}

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

.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.input-prefix-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix {
  position: absolute;
  left: 14px;
  font-weight: 700;
  color: var(--brand-blue);
  pointer-events: none;
}

.form-input.with-prefix {
  padding-left: 30px;
  font-family: monospace;
  font-size: 15px;
  text-transform: uppercase;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand-blue);
  color: #ffffff;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition-apple);
}

.btn-primary:hover {
  background: var(--brand-blue-hover);
}

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

.btn-secondary {
  display: inline-flex;
  align-items: center;
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition-apple);
}

.btn-secondary:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  padding: 8px 16px;
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: var(--transition-apple);
}

.btn-danger:hover {
  background: #ef4444;
  color: #ffffff;
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Alerts & Notifications
   ========================================================================== */
.alert-box {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
}

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

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #dc2626;
}

/* ==========================================================================
   Universal Popup Engine (#coc_popup)
   ========================================================================== */
#coc_popup.coc-popup {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  overflow-y: auto;
  transition: opacity 0.22s ease, visibility 0.22s ease;
  box-sizing: border-box;
}

#coc_popup.coc-popup.has-overlay {
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#coc_popup.coc-popup.no-overlay {
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

#coc_popup.coc-popup.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#coc_popup.coc-popup.active.no-overlay {
  pointer-events: none;
}

.coc-popup-card {
  position: relative;
  width: 400px;
  max-width: 100%;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 16px;
  padding: 22px 24px 24px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.05);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  pointer-events: auto;
  margin: auto;
}

#coc_popup.coc-popup.active .coc-popup-card {
  transform: scale(1) translateY(0);
}

html.dark .coc-popup-card {
  background: #14171d;
  border-color: #242933;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.coc-popup-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  border: none;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.coc-popup-close:hover {
  background: var(--border, rgba(0, 0, 0, 0.1));
  color: var(--text-primary, #111827);
  transform: scale(1.05);
}

html.dark .coc-popup-close {
  background: rgba(255, 255, 255, 0.06);
  color: #9ca3af;
}

html.dark .coc-popup-close:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.coc-popup-header {
  display: flex;
  align-items: center;
  min-height: 30px;
  margin-bottom: 18px;
  padding-right: 38px;
}

.coc-popup-title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.coc-popup-body {
  width: 100%;
}

@media (max-width: 480px) {
  #coc_popup.coc-popup {
    padding: 14px;
  }

  .coc-popup-card {
    padding: 20px 18px;
  }
}

/* ==========================================================================
   Hybrid Loading Indicators:
   1. Screen Overlay Loader (#coc_loader) for Popups & Global Transitions
   2. In-Button Spinner (.is-loading) for Local Element Actions
   ========================================================================== */
@keyframes cocSpin {
  to {
    transform: rotate(360deg);
  }
}

#coc_loader.coc-screen-loader {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.16s ease, visibility 0.16s ease;
}

#coc_loader.coc-screen-loader.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.coc-screen-spinner {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e5e7eb);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.24);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.92);
  transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

#coc_loader.coc-screen-loader.active .coc-screen-spinner {
  transform: scale(1);
}

html.dark .coc-screen-spinner {
  background: #14171d;
  border-color: #242933;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
}

.coc-screen-spinner::after {
  content: '';
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(0, 102, 204, 0.18);
  border-top-color: var(--brand-blue, #0066cc);
  animation: cocSpin 0.65s linear infinite;
}

html.dark .coc-screen-spinner::after {
  border-color: rgba(59, 130, 246, 0.22);
  border-top-color: #3b82f6;
}

/* Universal In-Button Spinner (.is-loading) */
.is-loading {
  position: relative !important;
  pointer-events: none !important;
  color: transparent !important;
  user-select: none;
}

.is-loading > * {
  opacity: 0 !important;
  transition: opacity 0.12s ease;
}

#headerUserMenuBtn.is-loading > * {
  opacity: 0.22 !important;
}

.is-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-left: -8px;
  border-radius: 50%;
  border: 2.2px solid rgba(0, 102, 204, 0.22);
  border-top-color: var(--brand-blue, #0066cc);
  animation: cocSpin 0.65s linear infinite;
  z-index: 3;
  box-sizing: border-box;
}

html.dark .is-loading::after {
  border-color: rgba(96, 165, 250, 0.25);
  border-top-color: #60a5fa;
}

.btn-primary.is-loading::after,
.btn-danger.is-loading:hover::after {
  border-color: rgba(255, 255, 255, 0.32);
  border-top-color: #ffffff;
}