/* ==========================================================
   Arena Ingressos — Portal CSS
   Layout do dashboard do produtor
   ========================================================== */

.portal-layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-bg);
}

/* ----------------------------------------------------------
   SIDEBAR
   ---------------------------------------------------------- */
.portal-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-primary-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition-slow);
}

.portal-sidebar__logo {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem 0.75rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  margin-bottom: 0.5rem;
  margin: 0 auto;
}

.sidebar__logo-img {
  height: 80px;
  width: auto;
  border-radius: 8px;
  padding: 2px 4px;
}

.portal-sidebar__section-label {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .3);
}

.portal-nav {
  list-style: none;
  padding: 0 0.75rem;
  flex: 1;
}

.portal-nav__item a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  color: rgba(255, 255, 255, .65);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  margin-bottom: 2px;
}

.portal-nav__item a:hover,
.portal-nav__item a.active {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.portal-nav__item a.active {
  background: rgba(76, 224, 224, .12);
  color: var(--color-cyan);
}

.portal-nav__item a.active img {
  opacity: 1 !important;
  filter: brightness(0) saturate(100%) invert(80%) sepia(40%) saturate(400%) hue-rotate(140deg);
}

.portal-nav__icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.portal-sidebar__footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, .06);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.portal-sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.portal-sidebar__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-cyan) 0%, #3dcece 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--color-primary-dark);
  flex-shrink: 0;
}

.portal-sidebar__user-info {
  min-width: 0;
}

.portal-sidebar__user-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-sidebar__user-plan {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, .4);
}

/* ----------------------------------------------------------
   TOPBAR
   ---------------------------------------------------------- */
.portal-topbar {
  height: 64px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}

.portal-topbar__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-primary);
}

.portal-topbar__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ----------------------------------------------------------
   MAIN CONTENT
   ---------------------------------------------------------- */
.portal-main {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.portal-content {
  padding: 2rem;
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
}

/* ----------------------------------------------------------
   METRIC CARDS (dashboard)
   ---------------------------------------------------------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  border-left: 4px solid var(--color-border);
  transition: box-shadow var(--transition-slow), transform var(--transition-slow);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.metric-card--cyan {
  border-left-color: var(--color-cyan);
}

.metric-card--orange {
  border-left-color: var(--color-orange);
}

.metric-card--green {
  border-left-color: var(--color-success);
}

.metric-card--blue {
  border-left-color: #3b82f6;
}

.metric-card__icon {
  font-size: 1.5rem;
  line-height: 1;
}

.metric-card__label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.metric-card__value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-primary);
  line-height: 1;
}

.metric-card__sub {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ----------------------------------------------------------
   DATA TABLE
   ---------------------------------------------------------- */
.data-table-wrapper {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

.data-table-header__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  padding: 0.75rem 1.5rem;
  background: var(--color-surface-2);
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  padding: 1rem 1.5rem;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--color-surface-2);
}

/* Status badges no portal */
.status-draft {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
}

.status-published {
  background: rgba(16, 185, 129, .15);
  color: #10b981;
}

.status-canceled {
  background: rgba(239, 68, 68, .15);
  color: #ef4444;
}

.status-finished {
  background: rgba(59, 130, 246, .15);
  color: #3b82f6;
}

/* ----------------------------------------------------------
   FORM PORTAL (criação de evento)
   ---------------------------------------------------------- */
.portal-form-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.portal-form-card__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.portal-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.portal-form-grid--full {
  grid-column: 1 / -1;
}

/* Category cards no portal */
.category-portal-card {
  border: 2px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition);
}

.category-portal-card:hover {
  border-color: var(--color-cyan);
}

.category-portal-card__header {
  background: linear-gradient(135deg, var(--color-primary) 0%, #254d78 100%);
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}

.category-portal-card__body {
  padding: 1.25rem;
}

.batch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  gap: 0.75rem;
}

.batch-row:last-child {
  margin-bottom: 0;
}

/* ----------------------------------------------------------
   Responsive Portal
   ---------------------------------------------------------- */
@media (max-width: 1024px) {
  .portal-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .portal-sidebar {
    transform: translateX(-100%);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-main {
    margin-left: 0;
  }

  .portal-topbar {
    padding: 0 1.25rem;
  }

  .portal-content {
    padding: 1.25rem;
  }

  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ----------------------------------------------------------
   DARK MODE overrides
   ---------------------------------------------------------- */
html[data-theme="dark"] .portal-topbar {
  background: var(--color-surface);
  border-bottom-color: var(--color-border);
}

html[data-theme="dark"] .portal-form-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .data-table-wrapper {
  background: var(--color-surface);
  border-color: var(--color-border);
}

html[data-theme="dark"] .data-table thead th {
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  border-color: var(--color-border);
}

html[data-theme="dark"] .data-table td {
  border-color: var(--color-border);
  color: var(--color-text);
}

html[data-theme="dark"] .data-table tr:hover td {
  background: var(--color-surface-2);
}

html[data-theme="dark"] .portal-form-card input,
html[data-theme="dark"] .portal-form-card select,
html[data-theme="dark"] .portal-form-card textarea {
  background: var(--color-surface-2);
  color: var(--color-text);
  border-color: var(--color-border);
}

html[data-theme="dark"] .batch-row {
  background: var(--color-surface-2);
}

html[data-theme="dark"] .category-portal-card__body {
  background: var(--color-surface);
  border-color: var(--color-border);
}

/* ----------------------------------------------------------
   DOCK MOBILE — barra de navegação inferior (mobile only)
   ---------------------------------------------------------- */
.portal-dock {
  display: none;
}

@media (max-width: 768px) {
  .portal-dock {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--sidebar-bg, #112840);
    border-top: 1px solid rgba(255, 255, 255, .1);
    padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: stretch;
  }

  .portal-dock__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    flex: 1;
    min-width: 0;
    padding: .3rem .25rem;
    color: rgba(255, 255, 255, .55);
    text-decoration: none;
    font-size: .62rem;
    font-weight: 600;
    background: none;
    border: none;
    cursor: pointer;
    transition: color .15s;
    -webkit-tap-highlight-color: transparent;
  }

  .portal-dock__item i {
    font-size: 1.15rem;
    line-height: 1;
  }

  .portal-dock__item.active,
  .portal-dock__item:hover {
    color: #4CE0E0;
  }

  /* Give content breathing room above the dock */
  .portal-content {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }

  /* Hamburger button visible on mobile */
  .portal-topbar__hamburger {
    display: block !important;
  }
}

/* ----------------------------------------------------------
   SIDEBAR OVERLAY — escurece fundo ao abrir sidebar no mobile
   ---------------------------------------------------------- */
.portal-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 149;
}

@media (max-width: 768px) {
  .portal-sidebar-overlay.active {
    display: block;
  }

  .portal-sidebar {
    z-index: 150;
  }
}

/* ----------------------------------------------------------
   FILTER BAR — barra de filtros/busca padronizada
   ---------------------------------------------------------- */
.portal-filter-bar {
  margin-bottom: 1.5rem;
}

.portal-filter-bar__form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
}

.portal-filter-bar__field {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.portal-filter-bar__icon {
  position: absolute;
  left: .85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: .85rem;
  pointer-events: none;
}

.portal-filter-bar__input {
  padding-left: 2.25rem !important;
}

.form-control--compact {
  padding-top: .5rem;
  padding-bottom: .5rem;
  font-size: .875rem;
  height: auto;
  min-width: 140px;
  max-width: 200px;
}

@media (max-width: 640px) {
  .portal-filter-bar__field {
    max-width: 100%;
    width: 100%;
  }

  .form-control--compact {
    max-width: 100%;
    width: 100%;
  }

  .portal-filter-bar__form {
    flex-direction: column;
    align-items: stretch;
  }

  .portal-filter-bar__form .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ----------------------------------------------------------
   MOBILE FIXES — formulários e lotes
   ---------------------------------------------------------- */

/* Garante que todos os inputs/selects não extrapolam o container */
.portal-form-card input,
.portal-form-card select,
.portal-form-card textarea,
.portal-form-card input[type="datetime-local"],
.portal-form-card input[type="number"],
.portal-form-card input[type="text"] {
  max-width: 100%;
  box-sizing: border-box;
}

/* form-control já tem width:100% mas reforça em mobile */
@media (max-width: 640px) {

  .portal-form-card {
    overflow-x: hidden;
  }

  /* Trix editor responsivo */
  trix-editor {
    overflow-x: auto;
    word-break: break-word;
  }

  /* form-grid em 1 coluna já cobre 1024px mas garante em telas menores */
  .portal-form-grid {
    grid-template-columns: 1fr;
  }

  /* Botões do formulário empilham no mobile */
  .portal-form-card>form>div[style*="display:flex"],
  .portal-form-card [style*="display:flex; gap:1rem"] {
    flex-wrap: wrap;
  }

  .portal-form-card .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
    min-width: 120px;
  }
}

/* batch-row: no mobile vira card empilhado */
@media (max-width: 640px) {
  .batch-row {
    flex-direction: column;
    align-items: stretch;
    gap: .6rem;
    padding: .9rem;
  }

  .batch-row>div {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Ações do batch: botões lado a lado */
  .batch-row>div:last-child {
    justify-content: flex-end;
    gap: .4rem;
  }

  /* capacity bar não fica deslocada */
  .capacity-bar {
    width: 100% !important;
    max-width: 120px;
  }

  /* Header de categoria responsivo */
  .category-portal-card__header {
    flex-direction: column;
    align-items: flex-start;
    gap: .6rem;
  }

  .category-portal-card__header>div:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    width: 100%;
  }

  .category-portal-card__header .btn {
    flex: 1;
    text-align: center;
    justify-content: center;
  }
}

/* ----------------------------------------------------------
   EVENT FORM — mobile específico
   ---------------------------------------------------------- */
@media (max-width: 640px) {

  /* datetime-local tem largura intrínseca no Safari/Chrome iOS */
  .portal-form-card input,
  .portal-form-card select,
  .portal-form-card textarea,
  .portal-form-card input[type="datetime-local"],
  .portal-form-card input[type="number"],
  .portal-form-card input[type="text"],
  .trix-wrapper {
    width: 95%;
    min-width: 0;
    font-size: .85rem;
    /* menor para caber no iPhone SE */
  }

  .cover-upload-preview {
    max-height: 160px;
    width: 95% !important;
  }

  #event-private {
    width: auto;
  }

  .form-label .badge {
    padding: 0;
  }


  /* Trix não extrapola */
  .trix-wrapper {
    overflow-x: hidden;
  }

  trix-toolbar {
    overflow-x: auto;
    white-space: nowrap;
  }

  /* form-card sem padding excessivo em mobile */
  .portal-form-card {
    padding: 1.25rem !important;
  }
}

/* ----------------------------------------------------------
   EVENTS INDEX — layout dual (tabela desktop / cards mobile)
   ---------------------------------------------------------- */
.events-table-desktop {
  display: block;
}

.events-cards-mobile {
  display: none;
}

@media (max-width: 768px) {
  .events-table-desktop {
    display: none;
  }

  .events-cards-mobile {
    display: flex;
    flex-direction: column;
    gap: .75rem;
  }
}

.event-card-mobile {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.event-card-mobile__header {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: 1rem 1.1rem .75rem;
  border-bottom: 1px solid var(--color-border);
}

.event-card-mobile__title {
  font-weight: 700;
  font-size: .95rem;
  color: var(--color-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-card-mobile__meta {
  font-size: .75rem;
  color: var(--color-text-muted);
  margin-top: .2rem;
}

.event-card-mobile__stats {
  display: flex;
  gap: 1rem;
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}

.event-card-mobile__stat {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 60px;
}

.event-card-mobile__stat-label {
  font-size: .7rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 600;
}

.event-card-mobile__stat-value {
  font-size: .9rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: .15rem;
}

.event-card-mobile__actions {
  display: flex;
  gap: .5rem;
  padding: .75rem 1.1rem;
  flex-wrap: wrap;
}

.event-card-mobile__actions .btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  min-width: 80px;
}