@import url("theme.css");

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fl-page);
  color: var(--fl-text);
}

a {
  color: var(--fl-red);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ── Layout ── */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page--auth {
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background:
    linear-gradient(135deg, rgba(211, 18, 42, 0.06) 0%, transparent 55%),
    var(--fl-page);
}

.page--hub {
  background: var(--fl-page);
}

/* ── Header ── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--fl-border);
  background: var(--fl-surface);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 0 rgba(17, 24, 39, 0.04);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header__logo {
  height: var(--fl-logo-height);
  width: auto;
  object-fit: contain;
}

.header__title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ── Auth card ── */

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  padding: 2.5rem 2rem;
  box-shadow: var(--fl-shadow-lg);
}

.auth-card__logo {
  height: var(--fl-logo-height-auth);
  width: auto;
  object-fit: contain;
  margin: 0 auto 1.5rem;
}

.auth-card__title {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 700;
  text-align: center;
}

.auth-card__subtitle {
  margin: 0 0 2rem;
  color: var(--fl-muted);
  text-align: center;
  font-size: 0.9rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: var(--fl-surface-muted);
  border-radius: 8px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  color: var(--fl-muted);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.auth-tab--active {
  background: var(--fl-red);
  color: var(--fl-text-on-red);
}

.auth-form {
  display: none;
  flex-direction: column;
  gap: 1rem;
}

.auth-form--active {
  display: flex;
}

.auth-status {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  line-height: 1.45;
}

.auth-status--info {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--fl-text);
}

.auth-status--error {
  background: rgba(211, 18, 42, 0.12);
  border: 1px solid rgba(211, 18, 42, 0.35);
  color: var(--fl-text);
}

.auth-status--success {
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--fl-text);
}

.otp-dev-code {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 1rem;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.otp-dev-code[hidden] {
  display: none;
}

.otp-dev-code__label {
  font-size: 0.8rem;
  color: var(--fl-muted);
}

.otp-dev-code__value {
  font-size: 1.6rem;
  letter-spacing: 0.28em;
  font-variant-numeric: tabular-nums;
  color: var(--fl-text);
}

.auth-step__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.auth-step__subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--fl-muted);
  line-height: 1.45;
}

.auth-step__actions {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.otp-input {
  letter-spacing: 0.35em;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 600;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--fl-muted);
}

.form-group input,
.form-group select {
  padding: 0.75rem 1rem;
  border: 1px solid var(--fl-border);
  border-radius: 8px;
  background: var(--fl-surface);
  color: var(--fl-text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--fl-red);
  box-shadow: 0 0 0 3px rgba(211, 18, 42, 0.12);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--fl-muted);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

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

.btn--primary {
  background: var(--fl-red);
  color: var(--fl-text-on-red);
}

.btn--primary:hover:not(:disabled) {
  background: var(--fl-red-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--fl-muted);
  border: 1px solid var(--fl-border);
}

.btn--ghost:hover:not(:disabled) {
  color: var(--fl-text);
  border-color: var(--fl-border-strong);
  background: var(--fl-surface-muted);
}

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

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

/* ── Hub main ── */

.hub-main {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.hub-hero {
  margin-bottom: 2rem;
}

.hub-hero h1 {
  margin: 0 0 0.5rem;
  font-size: 1.75rem;
  font-weight: 700;
}

.hub-hero p {
  margin: 0;
  color: var(--fl-muted);
}

.role-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--fl-surface-muted);
  border: 1px solid var(--fl-border);
}

.role-badge[data-role="admin"] {
  border-color: var(--fl-red);
  color: var(--fl-red);
}

.role-badge[data-role="jefatura"] {
  border-color: #f59e0b;
  color: #f59e0b;
}

.role-badge[data-role="am"] {
  border-color: #3b82f6;
  color: #3b82f6;
}

.role-badge[data-role="bdm"] {
  border-color: #10b981;
  color: #10b981;
}

.hub-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.stat-card {
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--fl-shadow);
}

.stat-card__value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--fl-red);
}

.stat-card__label {
  font-size: 0.8rem;
  color: var(--fl-muted);
}

.hub-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.65rem 1rem;
  border: 1px solid var(--fl-border);
  border-radius: 8px;
  background: var(--fl-surface);
  color: var(--fl-text);
  font-family: inherit;
}

.filter-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--fl-border);
  border-radius: 999px;
  background: var(--fl-surface);
  color: var(--fl-muted);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn--active {
  border-color: var(--fl-red);
  color: var(--fl-red);
  background: rgba(211, 18, 42, 0.06);
}

/* ── View toggle ── */

.filter-btn:hover {
  border-color: var(--fl-red);
  color: var(--fl-red);
}

.view-toggle {
  display: flex;
  gap: 0.35rem;
  background: var(--fl-surface-muted);
  border: 1px solid var(--fl-border);
  border-radius: 8px;
  padding: 4px;
}

.view-btn {
  padding: 0.45rem 0.85rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fl-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn--active {
  background: var(--fl-red);
  color: var(--fl-text-on-red);
}

.lang-switcher {
  display: flex;
  gap: 0.25rem;
  background: var(--fl-surface-muted);
  border: 1px solid var(--fl-border);
  border-radius: 8px;
  padding: 3px;
}

.lang-switcher--auth {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 20;
}

.lang-btn {
  padding: 0.35rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fl-muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.lang-btn--active {
  background: var(--fl-red);
  color: var(--fl-text-on-red);
}

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

.hub-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.hub-section__title {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fl-muted);
}

.hub-section .apps-grid,
.hub-section .apps-list {
  margin-bottom: 0;
}

.app-card {
  display: flex;
  flex-direction: column;
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  padding: 1.5rem;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  box-shadow: var(--fl-shadow);
}

.app-card:hover:not(.app-card--disabled) {
  border-color: var(--fl-red);
  transform: translateY(-2px);
  box-shadow: var(--fl-shadow-lg);
}

.app-card--disabled {
  opacity: 0.7;
}

.app-card__icon {
  width: 40px;
  height: 40px;
  color: var(--fl-red);
  margin-bottom: 1rem;
}

.app-card__icon svg {
  width: 100%;
  height: 100%;
}

.app-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.app-card__category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fl-muted);
}

.app-card__status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.app-card__status--active {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
}

.app-card__status--coming_soon {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
}

.app-card__title {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
}

.app-card__desc {
  margin: 0;
  font-size: 0.85rem;
  color: var(--fl-muted);
  line-height: 1.5;
  flex: 1;
}

.app-card__footer {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--fl-border);
}

.app-card__soon {
  font-size: 0.8rem;
  color: var(--fl-muted);
  font-style: italic;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 2rem 0 1rem;
  color: var(--fl-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.empty-state {
  color: var(--fl-muted);
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem;
}

/* ── App list view ── */

.apps-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.app-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 1rem;
  align-items: center;
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  border-radius: var(--fl-radius);
  padding: 1rem 1.25rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--fl-shadow);
}

.app-row:hover:not(.app-row--disabled) {
  border-color: var(--fl-red);
}

.app-row--disabled {
  opacity: 0.7;
}

.app-row__icon {
  width: 40px;
  height: 40px;
  color: var(--fl-red);
}

.app-row__icon svg {
  width: 100%;
  height: 100%;
}

.app-row__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.app-row__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.app-row__desc {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--fl-muted);
  line-height: 1.4;
}

.app-row__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  min-width: 140px;
}

/* ── Toast ── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--fl-surface);
  border: 1px solid var(--fl-border);
  color: var(--fl-text);
  box-shadow: var(--fl-shadow-lg);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 100;
  max-width: 360px;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.toast--warn {
  border-color: #f59e0b;
  color: #92400e;
  background: #fffbeb;
}

.toast--error {
  border-color: var(--fl-red);
  color: #991b1b;
  background: #fef2f2;
}

.toast--success {
  border-color: var(--fl-success);
  color: #065f46;
  background: #ecfdf5;
}

.alert-box {
  background: #fef2f2;
  border: 1px solid rgba(211, 18, 42, 0.25);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  color: #7f1d1d;
}

/* ── Responsive ── */

@media (max-width: 640px) {
  .header {
    padding: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .hub-main {
    padding: 1.25rem;
  }

  .hub-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .app-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .app-row__meta {
    align-items: flex-start;
    flex-direction: row;
    flex-wrap: wrap;
  }
}
