/* -------------------------------------------------------------------------
   GestFel CSS · 40-shell-tables.css
   Shell principal, menú lateral, tablas fluidas y avisos/notificaciones.
   Orden de carga: respetar la numeración de los ficheros para conservar
   la cascada original y evitar regresiones visuales.
   ------------------------------------------------------------------------- */

@layer layout {

/* -------------------------------------------------------------------------
   Menú lateral ocultable y contenido fluido en escritorio
   HTML: .desktop-sidebar-edge + aside.sidebar + main.app-main (layout.php)
   JS: initDesktopCollapsibleSidebar() (app.js)
   ------------------------------------------------------------------------- */
.desktop-sidebar-edge {
  display: none;
}

@media (min-width: 1101px) {
  html,
  body,
  .app-body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-top {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    width: 100%;
    max-width: none;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  /* Única hamburguesa visible en escritorio: la de cabecera. */
  .app-top > .sidebar-toggle {
    display: inline-flex;
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
    margin-right: .65rem;
    position: relative;
    z-index: 1300;
  }

  .app-shell {
    position: relative;
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 0;
    align-items: start;
    min-height: calc(100vh - 74px);
    width: 100%;
    max-width: none;
    box-sizing: border-box;
  }

  .app-shell > .desktop-sidebar-edge,
  body.sidebar-collapsed .app-shell > .desktop-sidebar-edge {
    display: block;
    position: fixed;
    left: 0;
    top: 74px;
    bottom: 0;
    width: 18px;
    z-index: 1195;
    cursor: pointer;
    background: linear-gradient(90deg, rgba(11, 125, 109, .10), rgba(11, 125, 109, 0)) !important;
  }

  .app-shell > .sidebar {
    grid-column: 1;
    grid-row: 1;
    width: 280px;
    max-width: 280px;
    min-width: 0;
    position: sticky;
    top: 74px;
    left: auto;
    height: calc(100vh - 74px);
    max-height: calc(100vh - 74px);
    overflow-y: auto;
    transform: translate3d(0, 0, 0);
    transition: transform 0.24s ease, opacity 0.18s ease, box-shadow 0.24s ease;
    z-index: 1000;
    box-shadow: none;
  }

  .app-shell > .app-main {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    width: 100%;
    max-width: none;
    margin: 0;
    padding-left: clamp(22px, 3vw, 42px);
    padding-right: clamp(22px, 3vw, 42px);
    box-sizing: border-box;
  }

  body.sidebar-collapsed .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.sidebar-collapsed .app-shell > .sidebar {
    position: fixed;
    left: 0;
    top: 74px;
    bottom: 0;
    height: calc(100vh - 74px);
    max-height: calc(100vh - 74px);
    transform: translate3d(calc(-100% - 8px), 0, 0);
    pointer-events: none;
    opacity: 0.98;
    box-shadow: 18px 0 42px rgba(15, 36, 55, 0.18);
  }

  body.sidebar-collapsed.sidebar-peek .app-shell > .sidebar,
  body.sidebar-collapsed .app-shell > .sidebar.open {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
  }

  body.sidebar-collapsed .app-shell > .app-main,
  body:not(.sidebar-collapsed) .app-shell > .app-main {
    width: 100%;
    max-width: none;
    min-width: 0;
    margin: 0;
    box-sizing: border-box;
  }

  body.sidebar-collapsed .app-shell > .app-main {
    grid-column: 1 / -1;
  }

  body:not(.sidebar-collapsed) .app-shell > .app-main {
    grid-column: 2;
  }

  .app-main > *,
  .app-main .page-head,
  .app-main .card,
  .app-main .listing-card,
  .app-main .table-wrap,
  .app-main .kpis,
  .app-main .grid {
    max-width: none;
    box-sizing: border-box;
  }

  .app-main .page-head,
  .app-main .card,
  .app-main .listing-card,
  .app-main .table-wrap {
    width: 100%;
  }

  body.drawer-open.sidebar-collapsed .app-shell > .sidebar,
  body.drawer-open.sidebar-collapsed.sidebar-peek .app-shell > .sidebar {
    transform: translate3d(calc(-100% - 8px), 0, 0);
    pointer-events: none;
  }
}

@media (max-width: 1100px) {
  .app-shell > .desktop-sidebar-edge,
  .desktop-sidebar-edge::after {
    display: none;
    content: none;
  }

  .app-shell {
    display: block;
  }

  .app-main {
    width: 100%;
    max-width: none;
    margin: 0;
  }

  body.sidebar-collapsed {
    overflow-x: hidden;
  }
}

/* Tablas y tarjetas fluidas */
.app-main,
.app-main > *,
.app-main .card,
.app-main .listing-card,
.app-main .table-wrap {
  min-width: 0;
  max-width: none;
  box-sizing: border-box;
}

.app-main .card,
.app-main .listing-card,
.app-main .table-wrap {
  width: 100%;
}

.table-wrap {
  display: block;
  overflow-x: auto;
  overflow-y: visible;
}

.table-wrap > table.table,
.table-wrap > .table,
table.table {
  width: 100%;
  min-width: 100%;
  max-width: none;
  table-layout: auto !important;
}

.table th,
.table td {
  box-sizing: border-box;
}

.table th:not(.actions),
.table td:not(.actions) {
  min-width: 8.5rem;
}

.table th:first-child,
.table td:first-child {
  min-width: 12rem;
}

.table th.actions,
.table td.actions,
.table .actions {
  min-width: max-content !important;
  white-space: nowrap !important;
}

@media (min-width: 1101px) {
  .app-main .grid.two.list-dominant-grid,
  .app-main .grid.two.module-list-first,
  .app-main .grid.two.list-dominant-grid > section.card,
  .app-main .grid.two.module-list-first > section.card,
  .app-main .grid.two.list-dominant-grid .table-wrap,
  .app-main .grid.two.module-list-first .table-wrap {
    width: 100%;
    max-width: none;
  }

  .app-main .grid.two.list-dominant-grid > section.card,
  .app-main .grid.two.module-list-first > section.card {
    overflow: visible !important;
  }
}

@media (max-width: 720px) {
  .table-wrap > table.table,
  .table-wrap > .table,
  table.table,
  .responsive-list-table {
    width: 100%;
    min-width: 0;
  }

  .table th:not(.actions),
  .table td:not(.actions),
  .table th:first-child,
  .table td:first-child {
    min-width: 0;
  }
}



/* Comunicaciones, reportes y menú lateral */
.recipient-selector {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  background: #fff;
}
.recipient-selector legend {
  padding: 0 .35rem;
  font-weight: 800;
  color: var(--ink);
}
.recipient-checklist {
  display: grid;
  gap: .45rem;
  max-height: 320px;
  overflow-y: auto;
  padding: .35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfefe;
}
.recipient-option {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  gap: .65rem;
  padding: .6rem .7rem;
  border-radius: 10px;
  cursor: pointer;
}
.recipient-option:hover,
.recipient-option:focus-within {
  background: var(--mint);
}
.recipient-option input {
  width: auto !important;
  min-width: 18px;
}
.recipient-option small {
  display: block;
  color: var(--muted);
  font-weight: 600;
}
.inline-report-form textarea {
  width: min(260px, 100%);
  min-height: 74px;
  resize: vertical;
  font: inherit;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: .7rem .85rem;
}
.admin-comment-note {
  display: inline-block;
  margin-top: .45rem;
  padding: .55rem .7rem;
  border-radius: 10px;
  background: #fff8e7;
  border: 1px solid #f1dfae;
  color: #493b17;
}

@media (min-width: 1101px) {
  body:not(.sidebar-collapsed) .app-shell {
    align-items: stretch;
    background: linear-gradient(90deg, #fff 0 280px, transparent 280px);
  }

  body:not(.sidebar-collapsed) .app-shell > .sidebar {
    height: auto;
    min-height: calc(100vh - 74px);
    max-height: none;
    align-self: stretch;
    overflow: visible;
  }

  body.sidebar-collapsed .app-shell {
    background: transparent;
  }
}

@media (max-width: 700px) {
  .recipient-checklist {
    max-height: 260px;
  }
  .inline-report-form textarea {
    width: 100%;
  }
}

/* Avisos leídos/borrables */
.notice-item,
.notification-actions-row,
.notification-item-title-row {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
}
.notice-item {
  justify-content: space-between;
  padding: .85rem 0;
  border-bottom: 1px solid var(--line);
}
.notice-item:last-of-type {
  border-bottom: 0;
}
.notice-item-body,
.notification-item-main {
  min-width: 0;
  flex: 1;
}
.notice-actions,
.notification-actions-row form {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin: 0;
}
.notification-item-title-row {
  justify-content: space-between;
  margin-bottom: .25rem;
}
.notification-actions-row {
  flex-wrap: wrap;
  align-items: center;
  margin-top: .65rem;
}
.btn-small {
  min-height: 0;
  padding: .45rem .7rem;
  font-size: .9rem;
  border-radius: 10px;
}
.btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fff;
}
.btn-danger:hover,
.btn-danger:focus {
  background: #991b1b;
  border-color: #991b1b;
}
.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: .25rem .55rem;
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.pill-warning {
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fed7aa;
}
.pill-muted {
  background: #eef2f7;
  color: var(--muted);
  border: 1px solid var(--line);
}
.notification-item.read {
  opacity: .82;
}

@media (max-width: 700px) {
  .notice-item,
  .notification-item-title-row {
    flex-direction: column;
    align-items: stretch;
  }
  .notice-actions,
  .notification-actions-row,
  .notification-actions-row form {
    width: 100%;
  }
  .notice-actions .btn,
  .notification-actions-row .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
}

} /* end @layer layout */
