/* SysCargaHorária - Modern Design System */

:root {
  --sys-primary: #1B2A4A;
  --sys-primary-light: #243660;
  --sys-primary-dark: #111d35;
  --sys-secondary: #F0AD4E;
  --sys-secondary-light: #f5c882;
  --sys-success: #198754;
  --sys-danger: #dc3545;
  --sys-warning: #ffc107;
  --sys-info: #0dcaf0;
  --sys-light: #f8f9fc;
  --sys-gray-100: #f8f9fa;
  --sys-gray-200: #e9ecef;
  --sys-gray-300: #dee2e6;
  --sys-gray-500: #adb5bd;
  --sys-gray-600: #6c757d;
  --sys-gray-700: #495057;
  --sys-gray-800: #343a40;
  --sys-body-bg: #f0f2f5;
  --sys-card-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --sys-card-shadow-hover: 0 10px 25px rgba(0,0,0,.1);
  --sidebar-width: 260px;
  --navbar-height: 60px;
  --sys-radius: 0.75rem;
  --sys-radius-sm: 0.5rem;
  --sys-transition: all 0.2s ease-in-out;
}

/* =================== GLOBAL =================== */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-body {
  background-color: var(--sys-body-bg);
}

.auth-body {
  background: linear-gradient(135deg, var(--sys-primary) 0%, #2c4a80 50%, var(--sys-primary-dark) 100%);
  min-height: 100vh;
}

/* =================== NAVBAR =================== */
.navbar-sys {
  background: var(--sys-primary) !important;
  height: var(--navbar-height);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  z-index: 1030;
}

.navbar-sys .navbar-brand {
  color: #fff !important;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.navbar-sys .navbar-brand span {
  color: var(--sys-secondary) !important;
}

.navbar-sys .nav-link {
  color: rgba(255,255,255,0.8) !important;
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--sys-transition);
  padding: 0.5rem 0.85rem !important;
  border-radius: var(--sys-radius-sm);
}

.navbar-sys .nav-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.1);
}

.navbar-sys .navbar-text {
  color: rgba(255,255,255,0.85) !important;
  font-size: 0.875rem;
}

.navbar-sys .navbar-toggler {
  border-color: rgba(255,255,255,0.2);
}

/* =================== SIDEBAR =================== */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - var(--navbar-height));
  max-height: calc(100vh - var(--navbar-height));
  background: var(--sys-primary);
  background: linear-gradient(180deg, var(--sys-primary) 0%, var(--sys-primary-dark) 100%);
  position: fixed;
  top: var(--navbar-height);
  left: 0;
  z-index: 1020;
  overflow-y: auto;
  transition: var(--sys-transition);
  border-right: 1px solid rgba(255,255,255,0.05);
  padding-bottom: 1rem;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}

.sidebar .sidebar-heading {
  color: rgba(255,255,255,0.35);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1.5rem 1.25rem 0.5rem;
}

.sidebar .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 400;
  border-left: 3px solid transparent;
  transition: var(--sys-transition);
  margin: 1px 0;
}

.sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border-left-color: rgba(240,173,78,0.5);
}

.sidebar .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.12);
  border-left-color: var(--sys-secondary);
  font-weight: 500;
}

.sidebar .nav-link i {
  margin-right: 0.6rem;
  width: 20px;
  text-align: center;
  font-size: 1rem;
  opacity: 0.85;
}

.sidebar .nav-link.active i,
.sidebar .nav-link:hover i {
  opacity: 1;
}

/* =================== MAIN CONTENT =================== */
.main-content {
  width: 100%;
  min-height: calc(100vh - var(--navbar-height));
  margin-top: var(--navbar-height);
  padding-bottom: 2rem;
}

.main-content.with-sidebar {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
}

/* =================== PAGE HEADER =================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--sys-gray-200);
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sys-primary);
  margin: 0;
  letter-spacing: -0.02em;
}

.page-header h1 i {
  color: var(--sys-secondary);
}

/* =================== CARDS =================== */
.card {
  border: none;
  border-radius: var(--sys-radius);
  box-shadow: var(--sys-card-shadow);
  transition: var(--sys-transition);
  background: #fff;
}

.card:hover {
  box-shadow: var(--sys-card-shadow-hover);
}

.card .card-header {
  background: #fff;
  border-bottom: 1px solid var(--sys-gray-200);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 1rem 1.25rem;
  border-radius: var(--sys-radius) var(--sys-radius) 0 0 !important;
  color: var(--sys-primary);
}

.card .card-body {
  padding: 1.25rem;
}

/* Dashboard cards */
.dashboard-card {
  border: none;
  border-radius: var(--sys-radius);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
  position: relative;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  transform: translate(20px, -20px);
}

.dashboard-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  transform: translate(30px, 30px);
}

.dashboard-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.18);
}

.dashboard-card .card-body {
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.dashboard-card .card-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.dashboard-card .card-counter {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.dashboard-card .card-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.card-primary {
  background: linear-gradient(135deg, var(--sys-primary) 0%, var(--sys-primary-light) 100%);
  color: #fff;
}

.card-secondary {
  background: linear-gradient(135deg, #e69a2e 0%, var(--sys-secondary) 100%);
  color: #fff;
}

.card-success-sys {
  background: linear-gradient(135deg, #146c43 0%, var(--sys-success) 100%);
  color: #fff;
}

.card-info-sys {
  background: linear-gradient(135deg, #0aa2c0 0%, var(--sys-info) 100%);
  color: #fff;
}

/* =================== TABLES =================== */
.table-sys {
  border-collapse: separate;
  border-spacing: 0;
}

.table-sys thead {
  background: var(--sys-primary);
  color: #fff;
}

.table-sys thead th {
  border: none;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.85rem 1rem;
  white-space: nowrap;
}

.table-sys thead th:first-child {
  border-radius: var(--sys-radius-sm) 0 0 0;
}

.table-sys thead th:last-child {
  border-radius: 0 var(--sys-radius-sm) 0 0;
}

.table-sys tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
  font-size: 0.9rem;
  color: var(--sys-gray-700);
  border-bottom: 1px solid var(--sys-gray-200);
}

.table-sys tbody tr:hover {
  background-color: rgba(27,42,74,0.03);
}

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

/* =================== BUTTONS =================== */
.btn {
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--sys-radius-sm);
  transition: var(--sys-transition);
  letter-spacing: 0.01em;
}

.btn-sys-primary {
  background: var(--sys-primary);
  border-color: var(--sys-primary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(27,42,74,0.2);
}

.btn-sys-primary:hover {
  background: var(--sys-primary-dark);
  border-color: var(--sys-primary-dark);
  color: #fff;
  box-shadow: 0 4px 8px rgba(27,42,74,0.3);
  transform: translateY(-1px);
}

.btn-sys-primary:active {
  transform: translateY(0);
}

.btn-sys-secondary {
  background: var(--sys-secondary);
  border-color: var(--sys-secondary);
  color: #fff;
  box-shadow: 0 2px 4px rgba(240,173,78,0.25);
}

.btn-sys-secondary:hover {
  background: #e09d3e;
  border-color: #e09d3e;
  color: #fff;
  box-shadow: 0 4px 8px rgba(240,173,78,0.35);
  transform: translateY(-1px);
}

.btn-sys-secondary:active {
  transform: translateY(0);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-outline-primary {
  border-color: var(--sys-primary);
  color: var(--sys-primary);
}

.btn-outline-primary:hover {
  background: var(--sys-primary);
  color: #fff;
}

/* =================== BADGES =================== */
.badge {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.4em 0.7em;
  border-radius: 50rem;
  letter-spacing: 0.02em;
}

.badge-aberto {
  background-color: #e7f5ff;
  color: #1971c2;
}

.badge-processando {
  background-color: #fff3cd;
  color: #856404;
}

.badge-devolvido {
  background-color: #f8d7da;
  color: #842029;
}

.badge-validado {
  background-color: #d1e7dd;
  color: #0a5028;
}

.badge-enviado {
  background-color: #e8daef;
  color: #5b2c8b;
}

.badge-apto_publicacao {
  background-color: #d1f2eb;
  color: #0d6e53;
}

.badge-publicado {
  background-color: var(--sys-primary);
  color: #fff;
}

/* =================== LOGIN =================== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: #fff;
  border-radius: 1.25rem;
  padding: 2.75rem;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  max-width: 440px;
  width: 100%;
  animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card .login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-card .login-logo h2 {
  color: var(--sys-primary);
  font-weight: 800;
  font-size: 1.75rem;
  letter-spacing: -0.03em;
}

.login-card .login-logo span {
  color: var(--sys-secondary);
}

.login-card .login-logo p {
  font-size: 0.85rem;
}

/* =================== FORMS =================== */
.form-sys .form-label {
  font-weight: 600;
  color: var(--sys-gray-700);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.form-sys .form-control,
.form-sys .form-select {
  border-radius: var(--sys-radius-sm);
  border: 1.5px solid var(--sys-gray-300);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  transition: var(--sys-transition);
}

.form-sys .form-control:focus,
.form-sys .form-select:focus {
  border-color: var(--sys-primary);
  box-shadow: 0 0 0 3px rgba(27,42,74,0.12);
}

.form-sys .form-text,
.form-sys .form-hint {
  font-size: 0.8rem;
  color: var(--sys-gray-500);
}

/* SimpleForm error styling */
.form-sys .is-invalid {
  border-color: var(--sys-danger);
}

.form-sys .invalid-feedback {
  font-size: 0.8rem;
}

/* =================== PAGINATION =================== */
.pagination {
  margin-top: 1.5rem;
  margin-bottom: 0;
}

.pagination .page-link {
  color: var(--sys-primary);
  border-radius: var(--sys-radius-sm) !important;
  margin: 0 2px;
  border: 1px solid var(--sys-gray-200);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.4rem 0.75rem;
}

.pagination .page-item.active .page-link {
  background: var(--sys-primary);
  border-color: var(--sys-primary);
  color: #fff;
}

.pagination .page-link:hover {
  background: var(--sys-gray-100);
  color: var(--sys-primary);
}

/* =================== ALERTS =================== */
.alert {
  border: none;
  border-radius: var(--sys-radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.85rem 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* =================== STATUS =================== */
.status-active { color: var(--sys-success); }
.status-inactive { color: var(--sys-danger); }

/* =================== DL (description lists) =================== */
dl.row dt {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--sys-gray-600);
  padding-bottom: 0.5rem;
}

dl.row dd {
  font-size: 0.9rem;
  color: var(--sys-gray-800);
  padding-bottom: 0.5rem;
}

/* =================== SEARCH FORM =================== */
.search-form-card {
  background: var(--sys-gray-100);
  border-radius: var(--sys-radius-sm);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  border: 1px solid var(--sys-gray-200);
}

/* =================== ACTION BUTTONS GROUP =================== */
.btn-actions {
  display: flex;
  gap: 0.35rem;
}

/* =================== OFFCANVAS (mobile sidebar) =================== */
.offcanvas-sys {
  background: var(--sys-primary) !important;
  background: linear-gradient(180deg, var(--sys-primary) 0%, var(--sys-primary-dark) 100%) !important;
  width: var(--sidebar-width) !important;
}

.offcanvas-sys .sidebar-heading {
  color: rgba(255,255,255,0.35);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1.5rem 1.25rem 0.5rem;
}

.offcanvas-sys .nav-link {
  color: rgba(255,255,255,0.7);
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  transition: var(--sys-transition);
}

.offcanvas-sys .nav-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

.offcanvas-sys .nav-link i {
  margin-right: 0.6rem;
  width: 20px;
  text-align: center;
}

/* =================== RESPONSIVE =================== */
@media (max-width: 768px) {
  .sidebar {
    margin-left: calc(var(--sidebar-width) * -1);
  }

  .sidebar.show {
    margin-left: 0;
  }

  .main-content.with-sidebar {
    margin-left: 0;
    width: 100%;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .login-card {
    padding: 1.75rem;
    margin: 0 1rem;
  }
}

@media (min-width: 769px) and (max-width: 1200px) {
  :root {
    --sidebar-width: 220px;
  }
}

/* =================== UTILITIES =================== */
.text-sys-primary { color: var(--sys-primary) !important; }
.text-sys-secondary { color: var(--sys-secondary) !important; }
.bg-sys-primary { background-color: var(--sys-primary) !important; }
.bg-sys-secondary { background-color: var(--sys-secondary) !important; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--sys-gray-500);
}
.empty-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}
.empty-state p {
  font-size: 1rem;
  margin: 0;
}

/* =================== UPLOAD OVERLAY =================== */
.upload-overlay-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9998;
}

.upload-overlay-content {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 9999;
  text-align: center;
}

/* Active Storage Direct Upload elements */
.direct-upload {
  display: inline-block;
  position: relative;
  padding: 2px 4px;
  margin: 0 3px 3px 0;
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  font-size: 11px;
  line-height: 1.3;
}

.direct-upload--pending {
  opacity: 0.6;
}

.direct-upload__progress {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  opacity: 0.2;
  background: var(--sys-secondary);
  transition: width 120ms ease-out, opacity 60ms 60ms ease-in;
}

.direct-upload--complete .direct-upload__progress {
  opacity: 0.4;
}

.direct-upload--error {
  border-color: red;
}

input[type=file][data-direct-upload-url][disabled] {
  display: none;
}

/* =================== RESPONSIVE ACTIVITY TABLE =================== */
/* On small screens, convert activity table rows into stacked card layout */
@media (max-width: 991.98px) {
  .table-responsive table.table-bordered thead {
    display: none;
  }

  .table-responsive table.table-bordered tbody tr.nested-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--sys-gray-300);
    border-radius: var(--sys-radius-sm);
    background: var(--sys-gray-100);
  }

  .table-responsive table.table-bordered tbody tr.nested-fields > td {
    display: flex;
    flex-direction: column;
    border: none;
    padding: 0.25rem 0;
    min-width: 0;
  }

  /* Tipo de Atividade - full width */
  .table-responsive table.table-bordered tbody tr.nested-fields > td:first-child {
    flex: 0 0 100%;
  }

  /* Descrição - full width */
  .table-responsive table.table-bordered tbody tr.nested-fields > td:nth-child(2) {
    flex: 1 1 100%;
  }

  /* CH Semanal + other fields - side by side */
  .table-responsive table.table-bordered tbody tr.nested-fields > td {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 120px;
  }

  /* Add labels before fields on mobile */
  .table-responsive table.table-bordered tbody tr.nested-fields > td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--sys-gray-600);
    margin-bottom: 0.25rem;
  }

  /* Actions column - auto width */
  .table-responsive table.table-bordered tbody tr.nested-fields > td:last-child {
    flex: 0 0 auto;
    align-self: flex-end;
  }

  /* Hours input wider on mobile */
  .table-responsive table.table-bordered tbody tr.nested-fields .hours-input {
    width: 100%;
    text-align: left;
  }

  /* Footer subtotal - keep as row */
  .table-responsive table.table-bordered tfoot tr {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .table-responsive table.table-bordered tfoot tr td {
    border: none;
    padding: 0;
  }

  .table-responsive table.table-bordered tfoot tr td[colspan] {
    display: none;
  }

  .table-responsive table.table-bordered tfoot tr td:not([colspan]) {
    display: inline;
  }

  .table-responsive table.table-bordered tfoot tr td.text-end {
    display: inline;
  }

  .table-responsive table.table-bordered tfoot tr td.text-center {
    display: inline;
  }
}

/* =================== ADD ACTIVITY BUTTON =================== */
.btn-add-activity {
  color: #fff;
  background-color: var(--sys-success);
  border-color: var(--sys-success);
  font-weight: 500;
}

.btn-add-activity:hover {
  color: #fff;
  background-color: #157347;
  border-color: #146c43;
}

