/**
 * League Manager — Core CSS
 *
 * App root, screen system, buttons, inputs, modals, toasts,
 * status pills, loading states. Uses design tokens from
 * css/core/variables.css.
 */

/* ========================================================
   ANIMATIONS
   ======================================================== */
@keyframes lmFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes lmSpin {
  to { transform: rotate(360deg); }
}

/* ========================================================
   APP ROOT
   ======================================================== */
.lm-app {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  min-height: 60vh;
  color: var(--text-primary);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--panel-shadow);
  overflow: hidden;
}

.lm-app::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--panel-rule);
  pointer-events: none;
}

.lm-app > * {
  position: relative;
  z-index: 1;
}

/* ========================================================
   SCREEN SYSTEM
   ======================================================== */
.lm-screen {
  display: none;
}

.lm-screen--active {
  display: block;
  animation: lmFadeIn var(--duration-normal) var(--ease-out);
}

.lm-screen__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.lm-screen__title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  color: var(--gold-500);
  letter-spacing: var(--tracking-wide);
  margin: 0;
}

/* ========================================================
   BUTTONS
   ======================================================== */
.lm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-button);
  font-size: var(--text-base);
  letter-spacing: var(--tracking-wide);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
  text-decoration: none;
  white-space: nowrap;
}

.lm-btn--primary {
  background: var(--gradient-gold);
  color: var(--text-on-gold);
  border-color: var(--gold-700);
  box-shadow: var(--shadow-sm);
}

.lm-btn--primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md), var(--shadow-glow-gold);
}

.lm-btn--secondary {
  background: var(--gradient-purple);
  color: var(--text-bright);
  border-color: var(--border-muted);
  box-shadow: var(--shadow-sm);
}

.lm-btn--secondary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lm-btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-muted);
}

.lm-btn--ghost:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.lm-btn--danger {
  background: var(--status-error);
  color: var(--text-bright);
  border-color: var(--status-error);
}

.lm-btn--danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.lm-btn--sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}

.lm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ========================================================
   INPUTS & SELECTS
   ======================================================== */
.lm-input,
.lm-select,
.lm-input--textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-elevated);
  border: 1px solid var(--border-muted);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast) var(--ease-out);
}

.lm-input:focus,
.lm-select:focus,
.lm-input--textarea:focus {
  outline: none;
  border-color: var(--gold-600);
  box-shadow: 0 0 0 2px var(--gold-alpha-15);
}

.lm-input--sm {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  max-width: 120px;
}

.lm-input--xs {
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  max-width: 80px;
}

.lm-input--textarea {
  min-height: 80px;
  resize: vertical;
}

.lm-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23A8887D' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
}

/* ── Field layout ── */
.lm-field {
  margin-bottom: var(--space-4);
}

.lm-field__label {
  display: block;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}

.lm-field--inline {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.lm-field--inline .lm-field__label {
  margin-bottom: 0;
  white-space: nowrap;
}

/* ── Checkbox / Radio ── */
.lm-checkbox,
.lm-radio {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  cursor: pointer;
}

.lm-checkbox input,
.lm-radio input {
  accent-color: var(--gold-600);
}

/* ========================================================
   STATUS PILLS
   ======================================================== */
.lm-status-pill {
  display: inline-block;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.lm-status-pill--draft {
  background: var(--white-alpha-8);
  color: var(--text-muted);
}

.lm-status-pill--registration {
  background: var(--status-info-bg);
  color: var(--status-info);
}

.lm-status-pill--active {
  background: var(--status-success-bg);
  color: var(--status-success);
}

.lm-status-pill--paused {
  background: var(--status-warning-bg);
  color: var(--status-warning);
}

.lm-status-pill--completed {
  background: var(--gold-alpha-15);
  color: var(--gold-500);
}

/* ========================================================
   BADGE
   ======================================================== */
.lm-badge {
  display: inline-block;
  padding: 2px var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  border-radius: var(--radius-sm);
}

.lm-badge--warning {
  background: var(--status-warning-bg);
  color: var(--status-warning);
}

/* ========================================================
   LOADING / SPINNER
   ======================================================== */
.lm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) 0;
  color: var(--text-muted);
  gap: var(--space-3);
}

.lm-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--gold-500);
  border-radius: 50%;
  animation: lmSpin 0.8s linear infinite;
}

/* ========================================================
   EMPTY STATE
   ======================================================== */
.lm-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ========================================================
   MODAL
   ======================================================== */
.lm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  background: var(--black-alpha-70);
}

.lm-modal--visible {
  display: flex;
}

.lm-modal__box {
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow-xl);
}

.lm-modal__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--gold-500);
  margin: 0 0 var(--space-3);
}

.lm-modal__text {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.lm-modal__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* ========================================================
   TOAST
   ======================================================== */
.lm-toast {
  position: fixed;
  bottom: var(--space-6);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out),
              transform var(--duration-normal) var(--ease-out);
  z-index: 1100;
  max-width: 90%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.lm-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.lm-toast--info {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.lm-toast--success {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid var(--status-success);
}

.lm-toast--error {
  background: var(--status-error-bg);
  color: var(--status-error);
  border: 1px solid var(--status-error);
}
