/*
 * Responsive redesign — Phase 3
 * Workforce, reports, settings, and remaining authenticated workspaces.
 */

.ofo-admin-card-table { min-width: 0; }

@media (max-width: 900px) {
  .ofo-module-grid-page,
  .settings-shell,
  .admin-page-shell,
  .tc-content { min-width: 0; }

  .ofo-module-grid-page .card,
  .settings-content-card,
  .admin-page-shell .card {
    min-width: 0;
    border-color: #dce3ec;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }

  .ofo-module-grid-page input:not([type="checkbox"]):not([type="radio"]),
  .ofo-module-grid-page select,
  .ofo-module-grid-page textarea,
  .settings-shell input:not([type="checkbox"]):not([type="radio"]),
  .settings-shell select,
  .settings-shell textarea,
  .settings-shell .btn,
  .admin-page-shell input:not([type="checkbox"]):not([type="radio"]),
  .admin-page-shell select,
  .admin-page-shell textarea,
  .admin-page-shell .btn { min-height: 44px; }

  .ofo-admin-card-wrap,
  .table-responsive:has(> .ofo-admin-card-table) { overflow: visible !important; }

  .ofo-admin-card-table {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    table-layout: auto !important;
  }

  .ofo-admin-card-table thead { display: none; }

  .ofo-admin-card-table tbody,
  .ofo-admin-card-table tfoot,
  .ofo-admin-card-table tr,
  .ofo-admin-card-table td {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .ofo-admin-card-table tr {
    margin-bottom: .75rem;
    padding: .75rem;
    border: 1px solid #dce3ec;
    border-radius: 12px;
    background: #fff;
  }

  .ofo-admin-card-table td {
    min-width: 0;
    padding: .26rem 0 !important;
    border: 0 !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }

  .ofo-admin-card-table .perpetua-cell-text {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    white-space: normal !important;
  }

  .ofo-admin-card-table code,
  .ofo-admin-card-table a {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .ofo-admin-card-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: .08rem;
    color: #64748b;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .025em;
    text-transform: uppercase;
  }

  .ofo-admin-card-table td[data-label=""]::before { display: none; }

  .ofo-employee-card-table td:nth-child(1)::before { content: "Name"; }
  .ofo-employee-card-table td:nth-child(2)::before { content: "Username"; }
  .ofo-employee-card-table td:nth-child(3)::before { content: "Email"; }
  .ofo-employee-card-table td:nth-child(4)::before { content: "PIN"; }
  .ofo-employee-card-table td:nth-child(5)::before { content: "Role"; }
  .ofo-employee-card-table td:nth-child(6)::before { content: "Status"; }
  .ofo-employee-card-table td:nth-child(7)::before { content: "Separation"; }
  .ofo-employee-card-table td:nth-child(8)::before { content: "Actions"; }

  .ofo-report-card-table td:nth-child(1)::before { content: "Name"; }
  .ofo-report-card-table td:nth-child(2)::before { content: "Source"; }
  .ofo-report-card-table td:nth-child(3)::before { content: "Description"; }
  .ofo-report-card-table td:nth-child(4)::before { content: "Actions"; }

  .ofo-payroll-card-table td:nth-child(1)::before { content: "Period"; }
  .ofo-payroll-card-table td:nth-child(2)::before { content: "Pay date"; }
  .ofo-payroll-card-table td:nth-child(3)::before { content: "Status"; }
  .ofo-payroll-card-table td:nth-child(4)::before { content: "Actions"; }

  .ofo-admin-card-table td[data-label="Actions"] {
    margin-top: .35rem;
    padding-top: .55rem !important;
    border-top: 1px solid #edf1f5 !important;
  }

  .ofo-employee-card-table td:nth-child(8),
  .ofo-report-card-table td:nth-child(4),
  .ofo-payroll-card-table td:nth-child(4) {
    margin-top: .35rem;
    padding-top: .55rem !important;
    border-top: 1px solid #edf1f5 !important;
  }

  .ofo-admin-card-table td[data-label="Actions"] > *,
  .ofo-admin-card-table td[data-label="Actions"] .d-inline-flex {
    display: flex !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: .45rem;
  }

  .ofo-admin-card-table td[data-label="Actions"] .btn { min-height: 44px; }

  .ofo-module-grid-page .row > [class*="col-md-"],
  .settings-shell .row > [class*="col-md-"],
  .admin-page-shell .row > [class*="col-md-"] { min-width: 0; }

  .settings-table-wrap { overflow: visible !important; }

  .task-table-wrap {
    border: 0;
    overflow: visible;
    background: transparent;
  }
  .task-table {
    display: block;
    width: 100% !important;
    max-width: 100%;
    min-width: 0 !important;
    table-layout: auto;
    border-collapse: separate !important;
  }
  .task-table thead { display: none; }
  .task-table tbody { display: grid; gap: .65rem; width: 100%; }
  .task-table tr {
    display: grid;
    width: 100%;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    background: #fff;
    overflow: hidden;
  }
  .task-table td {
    display: block;
    width: auto !important;
    padding: .55rem .75rem;
    border-bottom: 0;
  }
  .task-table td[data-mobile-label]::before {
    content: attr(data-mobile-label);
    display: block;
    margin-bottom: .18rem;
    color: #64748b;
    font-size: .7rem;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  .task-table td[data-mobile-label="Actions"]::before { display: none; }
  .task-table .task-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    justify-content: stretch;
  }
  .task-table .task-actions form { margin: 0 !important; }
  .task-table .task-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-width: 0;
    min-height: 44px;
  }
}

@media (min-width: 601px) and (max-width: 900px) {
  .ofo-employee-card-table tbody > tr,
  .ofo-payroll-detail-table tbody > tr:not(.table-light),
  .ofo-payroll-detail-table tfoot > tr {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .5rem 1rem;
  }

  .ofo-employee-card-table tbody > tr > td,
  .ofo-payroll-detail-table tbody > tr:not(.table-light) > td,
  .ofo-payroll-detail-table tfoot > tr > td {
    width: auto !important;
  }

  .ofo-payroll-detail-table tbody > tr:not(.table-light) > td:first-child,
  .ofo-payroll-detail-table tbody > tr:not(.table-light) > td:last-child,
  .ofo-payroll-detail-table tfoot > tr > td:first-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  .reports-page-body,
  .admin-page-shell,
  .settings-shell { padding-inline: 0; }

  .ofo-admin-card-table tr { border-radius: 10px; }

  .ofo-admin-card-table td[data-label="Actions"] .btn,
  .ofo-admin-card-table td[data-label="Actions"] form { flex: 1 1 8rem; }

  .ofo-admin-card-table td[data-label="Actions"] form .btn { width: 100%; }

  .ed-fields { grid-template-columns: minmax(0, 1fr) !important; }

  .calendar-toolbar,
  .task-toolbar,
  .ts-period-actions { min-width: 0; }

  .calendar-toolbar .btn,
  .task-toolbar .btn,
  .ts-period-actions .btn { min-height: 44px; }

  .day-popup .day-timeline { display: none; }
  .day-popup .day-popup-side {
    min-height: 0;
    padding: 1rem;
    border-top: 0;
  }
  .day-popup .calendar-form {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
  }
}

@media print {
  .ofo-admin-card-table { display: table !important; }
  .ofo-admin-card-table thead { display: table-header-group !important; }
  .ofo-admin-card-table tbody { display: table-row-group !important; }
  .ofo-admin-card-table tr { display: table-row !important; }
  .ofo-admin-card-table td { display: table-cell !important; }
  .ofo-admin-card-table td::before { display: none !important; }
}
