@use 'sass:color';

/* Variáveis */
$bg-page: #f9fafb;
$white: #ffffff;
$primary: #1c38c9;
$danger: #ef4444;
$warning: #f59e0b;
$success: #10b981;
$text-main: #111827;
$text-secondary: #4b5563;
$border: #e5e7eb;

:host { display: block; background-color: $bg-page; min-height: 100vh; }

.wrap { padding: 80px 0 40px; /* espaço para o header fixo */ }

.main-container {
  max-width: 900px; /* Mais estreito para leitura melhor */
  margin: 0 auto;
  padding: 0 20px;
}

/* HEADER */
.page-header {
  margin-bottom: 32px;
  text-align: center; /* Centralizado fica mais moderno */

  h2 { font-size: 28px; font-weight: 800; color: $text-main; margin-bottom: 8px; letter-spacing: -0.5px; }
  p { color: $text-secondary; font-size: 16px; margin-bottom: 24px; }
}

.bulk-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bulk-actions-bar {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.bulk-count {
  font-size: 12px;
  font-weight: 700;
  color: $text-secondary;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.bulk-selected {
  color: $text-main;
}

.select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: $text-secondary;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;

  input {
    width: 20px;
    height: 20px;
    accent-color: $primary;
  }
}

.bulk-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.bulk-btn {
  background: $white;
  border: 1px solid $border;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  color: $text-main;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  cursor: pointer;

  &:hover { border-color: $primary; color: $primary; }
  &:disabled { opacity: 0.6; cursor: default; }

  &.ghost { background: transparent; }
}

/* FILTROS (Estilo Tabs/Pills) */
.filters-bar {
  display: inline-flex;
  background: $white;
  padding: 6px;
  border-radius: 99px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);
  border: 1px solid rgba(0,0,0,0.05);
  gap: 4px;
  flex-wrap: wrap; justify-content: center;
}

.search-row {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.search-box {
  width: min(720px, 100%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  background: $white;
  box-shadow: 0 2px 10px rgba(0,0,0,0.03);

  i { color: $text-secondary; }

  input {
    border: none;
    outline: none;
    background: transparent;
    width: 100%;
    font-size: 14px;
    color: $text-main;
  }
}

.clear-btn {
  border: none;
  background: transparent;
  color: $text-secondary;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;

  &:hover { background: rgba(0,0,0,0.04); color: $text-main; }
}

.pill {
  border: none;
  background: transparent;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 13px; font-weight: 600; color: $text-secondary;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;

  &:hover { background: rgba(0,0,0,0.03); color: $text-main; }

  &.active {
    background: $text-main; color: $white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  }

  .count-badge {
    background: rgba(255,255,255,0.2);
    color: currentColor;
    padding: 1px 6px; border-radius: 10px; font-size: 10px;
    &.danger { background: $danger; color: #fff; }
  }
}

/* STATES */
.state-container {
  text-align: center; padding: 40px;
  color: $text-secondary; font-weight: 500;
  
  &.error { color: $danger; }
  .spinner-border { margin-bottom: 12px; }
}

.empty-state-large {
  text-align: center;
  padding: 60px 20px;
  
  .illustration {
    font-size: 64px; color: $success; opacity: 0.2;
    margin-bottom: 16px;
  }
  h3 { font-size: 20px; font-weight: 700; color: $text-main; }
  p { color: $text-secondary; }
}

/* LISTA */
.notif-list {
  display: flex; flex-direction: column; gap: 12px;
}

/* list-header-actions removido */

.list-item {
  background: $white;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.04);
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
  display: flex; align-items: flex-start;
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.06);
    .btn-action { opacity: 1; }
  }

  /* Status Colors */
  &.is-danger .status-strip { background: $danger; }
  &.is-warning .status-strip { background: $warning; }
  &.is-read { 
    opacity: 0.7; background: #fcfcfc; box-shadow: none; 
    .status-strip { background: $border; }
    &:hover { opacity: 1; }
  }
}

.item-select {
  margin-left: 8px;
  margin-right: 8px;
  min-width: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  align-self: center;

  input {
    width: 20px;
    height: 20px;
    accent-color: $primary;
  }
}

.status-strip {
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}

.item-icon {
  width: 40px; margin-left: 8px; margin-right: 16px;
  font-size: 24px; display: flex; align-items: center; justify-content: center;
  height: 40px;
  
  .bi-x-circle-fill { color: $danger; }
  .bi-clock-fill { color: $warning; }
  .bi-check2-circle { color: $primary; }
}

.item-content { flex: 1; min-width: 0; }

.content-top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 10px;
  margin-bottom: 10px;
}

.item-title {
  font-size: 16px;
  font-weight: 800;
  color: $text-main;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.separator { color: $text-secondary; }
.item-client { font-weight: 600; color: $text-secondary; }

.date-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
  min-width: 170px;
  text-align: left;
}

.date-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  &.green { background: rgba($success, 0.12); color: $success; }
  &.red { background: rgba($danger, 0.12); color: $danger; }
}

.item-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.meta-row { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: $text-secondary; font-weight: 700; }
.meta-value { font-size: 13px; font-weight: 600; color: $text-main; }

.badge-tag {
  font-size: 10px; text-transform: uppercase; padding: 4px 8px; border-radius: 999px;
  font-weight: 800; letter-spacing: 0.5px;
  width: fit-content;
  
  &.danger { background: rgba($danger, 0.1); color: $danger; }
  &.warn { background: rgba($warning, 0.1); color: color.adjust($warning, $lightness: -10%); }
  &.info { background: rgba($primary, 0.12); color: $primary; }
}

.item-actions {
  margin-left: 12px;
  align-self: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-action {
  background: white; border: 1px solid $border;
  padding: 6px 10px; border-radius: 7px;
  cursor: pointer;
  color: $text-main; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
  
  &:hover { border-color: $primary; color: $primary; }
  &:disabled { border-color: transparent; background: transparent; color: $success; cursor: default; }
  
  /* Mobile optimization: show button usually only on hover desktop, always mobile */
  @media(min-width: 768px) { opacity: 0.6; }
}

.btn-action.ghost {
  background: rgba($primary, 0.06);
  border-color: rgba($primary, 0.25);
  color: $primary;
}

.btn-action.renew {
  background: rgba($warning, 0.12);
  border-color: rgba($warning, 0.35);
  color: color.adjust($warning, $lightness: -22%);
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE (Central de Notificações)
   ========================================================================== */
@media (max-width: 768px) {
  .wrap {
    padding: calc(var(--app-header-offset, 72px) - 8px) 0 24px;
  }

  .main-container {
    padding: 0 12px;
  }

  .page-header {
    margin-bottom: 20px;
    text-align: center;

    .header-text {
      text-align: center;
      margin-bottom: 10px;
    }

    h2 {
      font-size: 22px;
      line-height: 1.12;
      margin-bottom: 6px;
      letter-spacing: -0.35px;
      word-break: break-word;
    }

    p {
      font-size: 13px;
      line-height: 1.35;
      margin-bottom: 14px;
    }
  }

  .filters-bar {
    display: flex;
    width: 100%;
    max-width: 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding: 4px;
    border-radius: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  }

  .pill {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 7px 10px;
    font-size: 12px;
    gap: 5px;

    .count-badge {
      font-size: 9px;
      padding: 1px 5px;
    }
  }

  .search-row {
    margin-top: 8px;
  }

  .search-box {
    width: 100%;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    min-height: 40px;

    i {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 14px;
      font-size: 14px;
      line-height: 1;
      flex: 0 0 auto;
    }

    input {
      min-width: 0;
      font-size: 16px; /* evita zoom no iPhone */
      line-height: 20px;
      height: 20px;
      padding: 0;

      &::placeholder {
        font-size: 12px;
        line-height: 20px;
        color: rgba($text-secondary, 0.95);
      }
    }
  }

  .clear-btn {
    flex: 0 0 auto;
  }

  .bulk-actions-bar {
    margin-top: 12px;
    gap: 10px;
    align-items: stretch;
  }

  .bulk-left {
    width: 100%;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
  }

  .select-all {
    flex: 0 0 auto;
    font-size: 11px;
    letter-spacing: 0.3px;

    input {
      width: 18px;
      height: 18px;
    }
  }

  .bulk-count {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 10px;
    line-height: 1.35;
    letter-spacing: 0.35px;
    margin-left: auto;
    text-align: right;
    white-space: normal;
  }

  .bulk-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bulk-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.2;
    border-radius: 10px;
    text-align: center;
    white-space: normal;
  }

  .state-container {
    padding: 24px 14px;
  }

  .empty-state-large {
    padding: 32px 14px;

    .illustration {
      font-size: 46px;
      margin-bottom: 10px;
    }

    h3 {
      font-size: 17px;
      margin-bottom: 6px;
    }

    p {
      font-size: 13px;
      line-height: 1.35;
      margin-bottom: 0;
    }
  }

  .notif-list {
    gap: 10px;
  }

  .list-item {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: 14px;

    &:hover {
      transform: none;
      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.04);
    }
  }

  .item-select {
    margin: 0;
    min-width: 20px;
    align-self: center;

    input {
      width: 18px;
      height: 18px;
    }
  }

  .item-icon {
    width: 30px;
    height: 30px;
    margin: 0;
    font-size: 18px;
    align-self: start;
  }

  .item-content {
    min-width: 0;
  }

  .content-top {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
  }

  .item-title {
    font-size: 14px;
    line-height: 1.25;
    gap: 4px;
  }

  .separator {
    display: none;
  }

  .item-client {
    display: block;
    width: 100%;
    overflow-wrap: anywhere;
  }

  .date-stack {
    width: 100%;
    min-width: 0;
    align-items: flex-start;
    text-align: left;
    gap: 4px;
  }

  .date-pill {
    font-size: 10px;
    padding: 4px 7px;
    letter-spacing: 0.25px;
    line-height: 1.2;
    white-space: normal;
  }

  .item-meta-grid {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .meta-row {
    gap: 3px;
  }

  .meta-label {
    font-size: 10px;
    letter-spacing: 0.35px;
  }

  .meta-value {
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }

  .badge-tag {
    font-size: 9px;
    letter-spacing: 0.35px;
    padding: 4px 7px;
  }

  .item-actions {
    grid-column: 1 / -1;
    margin: 2px 0 0 0;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .btn-action {
    width: 100%;
    justify-content: center;
    padding: 6px 8px;
    border-radius: 9px;
    font-size: 11px;
    gap: 6px;
  }

  .btn-action .d-none.d-md-inline {
    display: inline !important;
  }
}

@media (max-width: 420px) {
  .wrap {
    padding: calc(var(--app-header-offset, 72px) - 10px) 0 24px;
  }

  .main-container {
    padding: 0 10px;
  }

  .page-header {
    .header-text {
      margin-bottom: 8px;
    }

    h2 {
      font-size: 20px;
    }

    p {
      font-size: 12px;
      margin-bottom: 12px;
    }
  }

  .filters-bar {
    border-radius: 12px;
  }

  .pill {
    padding: 6px 9px;
    font-size: 11px;
    gap: 4px;
  }

  .search-box {
    padding: 8px 9px;
    gap: 7px;

    input::placeholder {
      font-size: 11px;
      letter-spacing: -0.1px;
    }
  }

  .bulk-btn {
    font-size: 10px;
    padding: 8px 8px;
  }

  .bulk-left {
    gap: 6px;
  }

  .bulk-count {
    font-size: 9px;
    letter-spacing: 0.25px;
  }

  .list-item {
    gap: 8px;
    padding: 11px 10px 11px 12px;
  }

  .item-title {
    font-size: 13px;
  }

  .date-pill {
    font-size: 9px;
    letter-spacing: 0.15px;
  }

  .meta-value {
    font-size: 11px;
  }

  .btn-action {
    font-size: 10px;
    padding: 6px 7px;
  }
}
