/* ============================================================
   AykaFin Design System — Global Permanent Styles
   Loads after aykafin-custom.css. No scoping, no toggle.
   Rule: enhance layout, spacing, mobile. Never override
   functionality. Uses Acorn CSS vars (--primary, --separator…).
   ============================================================ */

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --af-radius:     10px;
  --af-radius-sm:  6px;
  --af-radius-lg:  16px;
  --af-transition: 0.15s ease;
  --af-shadow:     0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.06);
  --af-shadow-md:  0 4px 16px rgba(0,0,0,0.10);
}

/* ============================================================
   PAGE HEADER — proper title size + mobile button stack
   ============================================================ */
.page-title-container h1,
.page-title-container h1.display-4 {
  font-size: 1.5rem !important;
  font-weight: 700 !important;
  letter-spacing: -0.3px !important;
  line-height: 1.25 !important;
}

@media (max-width: 767px) {
  .page-title-container h1,
  .page-title-container h1.display-4 {
    font-size: 1.2rem !important;
  }
  .page-title-container .col-12.col-md-5 {
    margin-top: 0.75rem;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
  }
  .page-title-container .col-12.col-md-5 .btn {
    flex: 1 1 auto;
    min-width: 110px;
    justify-content: center;
    min-height: 44px;
  }
}

/* ============================================================
   DATA TABLE WRAPPER — horizontal scroll on mobile
   ============================================================ */
.data-table-boxed {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Ensure the table itself is wide enough to scroll */
.data-table-boxed table {
  min-width: 480px;
}

/* ============================================================
   TABLE — cleaner header, better rows
   ============================================================ */
table.dataTable thead th,
.table thead th {
  font-size: 0.72rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.6px !important;
  padding: 10px 14px !important;
  white-space: nowrap;
  border-bottom-width: 2px !important;
}

table.dataTable tbody td,
.table tbody td {
  padding: 12px 14px !important;
  vertical-align: middle !important;
  font-size: 0.875rem !important;
}

/* ============================================================
   ACTION ICON BUTTONS — larger tap targets, tooltip-ready
   ============================================================ */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--af-radius-sm);
  border: 1px solid var(--separator, #ddd);
  background: transparent;
  color: var(--body, #4e4e4e);
  transition: background var(--af-transition), color var(--af-transition), border-color var(--af-transition);
  cursor: pointer;
  text-decoration: none;
}
.btn-action:hover {
  background: var(--background, #f9f9f9);
  color: var(--primary, #2499e3);
  border-color: var(--primary, #2499e3);
  text-decoration: none;
}
.btn-action.btn-action-danger:hover {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fca5a5;
}
.btn-action.btn-action-success:hover {
  background: #dcfce7;
  color: #16a34a;
  border-color: #86efac;
}

@media (max-width: 767px) {
  .btn-action {
    width: 40px;
    height: 40px;
  }
}

/* ============================================================
   NAV TABS — horizontal scroll on mobile, clean active state
   ============================================================ */
.nav-tabs {
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  border-bottom-width: 2px !important;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-item { flex-shrink: 0 !important; }

.nav-tabs .nav-link {
  font-weight: 600 !important;
  font-size: 0.875rem !important;
  white-space: nowrap !important;
  padding: 10px 18px !important;
  border: none !important;
  transition: background var(--af-transition), color var(--af-transition) !important;
}

/* ============================================================
   MODAL — centered on desktop, full-screen on mobile
   ============================================================ */
.modal-content {
  border-radius: var(--af-radius-lg) !important;
}
.modal-header {
  border-radius: var(--af-radius-lg) var(--af-radius-lg) 0 0 !important;
}

@media (max-width: 767px) {
  .modal.modal-right .modal-dialog,
  .modal-dialog {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }
  .modal.modal-right .modal-content,
  .modal-dialog .modal-content {
    border-radius: 0 !important;
    min-height: 100dvh !important;
  }
}

/* ============================================================
   PERMISSION CARDS (role_detail) — stack on mobile
   ============================================================ */
@media (max-width: 575px) {
  .card-body [id^="tab_div_"] {
    flex-direction: column-reverse !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  .card-body [id^="tab_div_"] .menu_tab.btn {
    width: 100% !important;
    text-align: center !important;
    justify-content: center !important;
    min-height: 44px;
  }
  .card-body [id^="tab_div_"] table.w-60 {
    width: 100% !important;
  }
}

/* ============================================================
   CHECKBOXES — larger tap targets
   ============================================================ */
.form-check-input {
  width: 18px !important;
  height: 18px !important;
  cursor: pointer;
  border-radius: 4px !important;
}

/* ============================================================
   DATATABLES PAGINATION — better mobile tap targets
   ============================================================ */
.dataTables_wrapper .page-link {
  min-width: 36px;
  min-height: 36px;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length {
  font-size: 0.8rem;
}

@media (max-width: 767px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter,
  .dataTables_wrapper .dataTables_info {
    text-align: left !important;
  }
}

/* ============================================================
   FORM LABELS — consistent small uppercase style
   ============================================================ */
.modal .form-label,
.card .form-label {
  font-size: 0.75rem !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  color: var(--muted, #afafaf) !important;
  margin-bottom: 0.35rem !important;
}

/* ============================================================
   SEARCH INPUT — full width on mobile
   ============================================================ */
@media (max-width: 767px) {
  .search-input-container {
    width: 100% !important;
  }
}

/* ============================================================
   CARD — remove overflow:hidden so dropdown menus aren't clipped
   ============================================================ */
.card {
  overflow: visible !important;
}
/* But keep table cards clipping for clean borders */
.data-table-boxed .card {
  overflow: hidden !important;
}

/* ============================================================
   DATATABLES WRAPPER — global horizontal scroll fix
   Applies to ALL DataTable instances regardless of wrapper class
   ============================================================ */
.dataTables_wrapper {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   INLINE TRANSFORM HOVERS — global neutralize
   Prevents ALL buttons from physically jumping on hover.
   Card hover transforms are intentional UX and are NOT targeted here.
   ============================================================ */
a.btn:hover,
button.btn:hover,
input.btn:hover,
.action-buttons .btn:hover,
.btn-group .btn:hover {
  transform: none !important;
}

/* ============================================================
   MODAL FOOTER — always use gap between buttons
   ============================================================ */
.modal-footer {
  gap: 0.5rem !important;
  flex-wrap: wrap;
}
.modal-footer .btn {
  min-height: 40px;
}

/* ============================================================
   FORM GROUP SPACING in modals/cards — consistent
   ============================================================ */
.modal .mb-3:last-child,
.modal .mb-3:last-of-type {
  margin-bottom: 0 !important;
}
