/* SoluECF responsive shell refinements.
   Layout only: keeps the canonical palette, typography and components intact. */

@media screen and (max-width: 1180px) {
  .portal-header {
    padding-inline: 16px !important;
  }

  .portal-content {
    padding: 16px !important;
  }

  .portal-content .ant-card {
    min-width: 0;
  }

  .listing-toolbar {
    display: grid !important;
    grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(150px, 1fr));
    align-items: center;
    gap: 8px !important;
  }

  .listing-toolbar > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
  }

  .portal-content .ant-table-wrapper {
    max-width: 100%;
  }

  .portal-content .ant-table-container {
    border-radius: 10px;
  }

  .portal-content .ant-table-content,
  .portal-content .ant-table-body {
    overflow-x: auto !important;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
  }

  .portal-content .metrics + .ant-card th:last-child,
  .portal-content .metrics + .ant-card td:last-child {
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 128px;
    white-space: nowrap;
    background: #fff;
    box-shadow: -10px 0 16px -16px rgba(15, 35, 55, .65);
  }

  .portal-content .metrics + .ant-card th:last-child {
    z-index: 3;
    background: #f6f8fb !important;
  }
}

/* Wide administrative listings: compact on tablets, readable cards on phones. */
@media (min-width: 821px) and (max-width: 1280px) {
  table.soluecf-wide-table {
    width: 1080px !important;
    min-width: 1080px !important;
    table-layout: fixed !important;
  }

  table.soluecf-wide-table th,
  table.soluecf-wide-table td {
    padding: 9px 7px !important;
    font-size: 12px !important;
  }

  table.soluecf-wide-table th:first-child,
  table.soluecf-wide-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 5px 0 10px rgba(15, 42, 67, .05);
  }

  table.soluecf-wide-table th:first-child {
    z-index: 3;
    background: #f5f7fa;
  }

  table.soluecf-comprobantes-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }

  table.soluecf-comprobantes-table th:nth-child(3),
  table.soluecf-comprobantes-table td:nth-child(3),
  table.soluecf-comprobantes-table th:nth-child(4),
  table.soluecf-comprobantes-table td:nth-child(4),
  table.soluecf-comprobantes-table th:nth-child(7),
  table.soluecf-comprobantes-table td:nth-child(7),
  table.soluecf-comprobantes-table th:nth-child(8),
  table.soluecf-comprobantes-table td:nth-child(8) {
    display: none !important;
  }

  table.soluecf-comprobantes-table col:nth-child(3),
  table.soluecf-comprobantes-table col:nth-child(4),
  table.soluecf-comprobantes-table col:nth-child(7),
  table.soluecf-comprobantes-table col:nth-child(8) {
    display: none !important;
  }

  table.soluecf-comprobantes-table th:nth-child(1) { width: 26% !important; }
  table.soluecf-comprobantes-table th:nth-child(2) { width: 24% !important; }
  table.soluecf-comprobantes-table th:nth-child(5) { width: 18% !important; }
  table.soluecf-comprobantes-table th:nth-child(6) { width: 15% !important; }
  table.soluecf-comprobantes-table th:nth-child(9) { width: 17% !important; }
}

@media (max-width: 820px) {
  .ant-table-wrapper:has(table.soluecf-wide-table)::before { display: none !important; }
  table.soluecf-wide-table { display: block !important; width: 100% !important; min-width: 0 !important; }
  table.soluecf-wide-table thead,
  table.soluecf-wide-table colgroup { display: none !important; }
  table.soluecf-wide-table tbody { display: grid !important; gap: 10px; width: 100%; }
  table.soluecf-wide-table tbody tr {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    width: 100% !important;
    padding: 10px 12px;
    border: 1px solid #e3e9f2;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(15, 42, 67, .04);
  }
  table.soluecf-wide-table tbody tr.ant-table-placeholder { display: block !important; }
  table.soluecf-wide-table tbody td {
    display: block !important;
    width: auto !important;
    min-width: 0 !important;
    padding: 7px 5px !important;
    border: 0 !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    background: transparent !important;
  }
  table.soluecf-wide-table tbody td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: #8290a3;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .045em;
    line-height: 1.2;
    text-transform: uppercase;
  }
  table.soluecf-wide-table tbody td:last-child:nth-child(odd) { grid-column: 1 / -1; }
  table.soluecf-wide-table tfoot { display: none !important; }
}

@media screen and (max-width: 820px) {
  .portal > .ant-layout-sider.portal-sider {
    position: fixed !important;
    inset: 0 auto 0 0;
    z-index: 1050;
    width: min(280px, 84vw) !important;
    min-width: min(280px, 84vw) !important;
    max-width: min(280px, 84vw) !important;
    flex: 0 0 min(280px, 84vw) !important;
    transform: translateX(0);
    box-shadow: 20px 0 45px rgba(15, 35, 55, .22);
    transition: transform .22s ease, box-shadow .22s ease;
  }

  .portal > .ant-layout-sider.portal-sider.ant-layout-sider-collapsed {
    transform: translateX(-105%);
    box-shadow: none;
    pointer-events: none;
  }

  .portal-sider.ant-layout-sider-collapsed + .ant-layout {
    margin-left: 0 !important;
  }

  .portal-sider .brand,
  .portal-sider .account,
  .portal-sider .sider-docs {
    opacity: 1 !important;
  }

  .portal-header {
    height: auto !important;
    min-height: 66px;
    padding: 10px 12px !important;
    gap: 9px !important;
  }

  .portal-header > div:nth-child(2) {
    min-width: 0;
  }

  .portal-header .overline {
    display: none;
  }

  .portal-header h3 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px !important;
  }

  .portal-header .header-end {
    min-width: 0;
    margin-left: auto;
  }

  .portal-header .active-company {
    max-width: 168px !important;
    min-width: 0;
    padding: 6px 8px !important;
  }

  .portal-header .active-company strong {
    max-width: 120px !important;
  }

  .portal-content {
    padding: 12px !important;
    overflow-x: hidden !important;
  }

  .portal-content > .ant-flex:first-child {
    align-items: flex-start !important;
    gap: 8px !important;
  }

  .portal-content h2 {
    font-size: 19px !important;
  }

  .metrics,
  .operations-metrics,
  .certification-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .metric .ant-card-body {
    padding: 12px !important;
  }

  .metric .ant-statistic-title {
    min-height: 34px;
    margin-bottom: 2px !important;
    line-height: 1.2;
  }

  .metric .ant-statistic-content {
    font-size: 20px !important;
  }

  .listing-toolbar,
  .filters.listing-toolbar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    width: 100%;
    margin-bottom: 12px !important;
  }

  .listing-toolbar > :first-child {
    grid-column: 1 / -1;
  }

  .portal-content .ant-card-body {
    padding: 12px !important;
  }

  .portal-content .ant-table-wrapper {
    position: relative;
    margin-inline: -4px;
    padding-bottom: 3px;
  }

  .portal-content .ant-table-wrapper::after {
    content: "Desliza para ver más";
    display: block;
    padding: 7px 4px 0;
    color: #7b8b9c;
    font-size: 10px;
    text-align: right;
  }

  .portal-content .ant-table-thead > tr > th,
  .portal-content .ant-table-tbody > tr > td {
    white-space: nowrap;
  }

  .portal-content .ant-table-thead > tr > th:first-child,
  .portal-content .ant-table-tbody > tr > td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
  }

  .portal-content .ant-table-thead > tr > th:first-child {
    z-index: 3;
    background: #f6f8fb !important;
  }

  .editor-grid,
  .dashboard-grid,
  .fiscal-tables,
  .company-profile-grid,
  .template-showcase,
  .template-type-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .json-editor {
    min-height: 360px !important;
    font-size: 11px !important;
  }

  .ant-modal-root .ant-modal {
    width: calc(100vw - 20px) !important;
    max-width: none !important;
    margin: 10px auto !important;
    top: 0 !important;
    padding-bottom: 0 !important;
  }

  .ant-modal-root .ant-modal-content {
    max-height: calc(100dvh - 20px);
    padding: 0 !important;
    overflow: hidden;
    border-radius: 14px !important;
  }

  .ant-modal-root .ant-modal-header {
    position: sticky;
    top: 0;
    z-index: 4;
    margin: 0 !important;
    padding: 18px 20px 14px !important;
    border-bottom: 1px solid #edf0f4;
    background: #fff;
  }

  .ant-modal-root .ant-modal-body {
    max-height: calc(100dvh - 134px);
    padding: 16px 20px !important;
    overflow-y: auto;
  }

  .ant-modal-root .ant-modal-footer {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin: 0 !important;
    padding: 12px 20px !important;
    border-top: 1px solid #edf0f4;
    background: #fff;
  }

  .ant-modal-root .ant-modal-footer .ant-btn {
    min-height: 40px;
  }

  .ant-modal-root .form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .ant-modal-root .ant-upload-wrapper,
  .ant-modal-root .ant-upload,
  .ant-modal-root .ant-upload-select {
    max-width: 100%;
  }

  .ant-modal-root input[type="file"] {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media screen and (max-width: 520px) {
  .portal-header .active-company {
    max-width: 138px !important;
  }

  .portal-header .active-company strong {
    max-width: 92px !important;
  }

  .metrics,
  .operations-metrics,
  .certification-metrics {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .listing-toolbar,
  .filters.listing-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .listing-toolbar > * {
    grid-column: 1 !important;
  }

  .ant-modal-root .ant-modal-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .ant-modal-root .ant-modal-footer .ant-btn {
    width: 100%;
    margin-inline-start: 0 !important;
  }

  .ant-modal-root .ant-modal-footer .ant-btn:only-child,
  .ant-modal-root .ant-modal-footer .ant-btn:last-child:nth-child(3) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  table.soluecf-wide-table tbody tr.ant-table-measure-row {
    display: none !important;
  }

  table.soluecf-wide-table tbody td,
  table.soluecf-wide-table tbody td:first-child,
  table.soluecf-wide-table tbody td:last-child {
    position: static !important;
    inset: auto !important;
    height: auto !important;
    min-height: 48px;
    box-shadow: none !important;
  }
}


