/* ============================================================
   Rahnivo Mobile Pro — Professional mobile experience
   Loaded after AdminLTE. Transforms the desktop admin panel
   into a modern, touch-friendly mobile app interface.
   ============================================================ */

/* ---------- 1. Global mobile reset ---------- */
@media (max-width: 991.98px) {
  html, body {
    overflow-x: hidden !important;
    -webkit-text-size-adjust: 100%;
  }
  body {
    font-size: 14px;
    background: #f4f6f9;
  }

  /* ---------- 2. Sidebar: fully hidden until toggled ---------- */
  .main-sidebar,
  .main-sidebar::before {
    margin-left: -250px !important;
    box-shadow: none !important;
    transition: margin-left 0.3s ease-in-out !important;
  }
  body.sidebar-open .main-sidebar,
  body.sidebar-open .main-sidebar::before {
    margin-left: 0 !important;
    box-shadow: 4px 0 16px rgba(0,0,0,0.3) !important;
  }
  /* Sidebar becomes a proper slide-over drawer */
  body.sidebar-open .main-sidebar {
    position: fixed !important;
    top: 0; bottom: 0; left: 0;
    z-index: 1040;
    width: 260px;
  }
  /* Darken background when drawer open */
  body.sidebar-open::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1039;
  }

/* ---------- 3. Layout: full-width content ---------- */
  .content-wrapper,
  .content-wrapper::before,
  .main-footer,
  .main-footer::before,
  .main-header,
  .main-header::before {
    margin-left: 0 !important;
  }
  .content-wrapper {
    padding: 0 !important;
    min-height: 100vh;
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100vw !important;
  }
  /* Kill any leftover sidebar-mini or collapsed-state margins */
  body.sidebar-mini .content-wrapper,
  body.sidebar-mini-md .content-wrapper,
  body.sidebar-collapse .content-wrapper,
  body.layout-fixed .content-wrapper {
    margin-left: 0 !important;
  }
  /* Force containers to full width */
  .content-wrapper .container,
  .content-wrapper .container-fluid {
    width: 100% !important;
    max-width: 100% !important;
    padding-left: 12px !important;
    padding-right: 12px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* ---------- 4. Top navbar: app-style ---------- */
  .main-header {
    position: sticky !important;
    top: 0;
    left: 0 !important;
    right: 0 !important;
    z-index: 1030;
    border-bottom: 2px solid #22D3EE !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  }
  .main-header .navbar-nav .nav-link {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  /* ---------- 5. Content header: compact page titles ---------- */
  .content-header {
    padding: 14px 14px 6px 14px;
  }
  .content-header h1 {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
  }
  .content-header .breadcrumb {
    font-size: 12px;
    padding: 4px 0;
    margin: 4px 0 0 0;
    background: transparent;
  }

  /* ---------- 6. Content body ---------- */
  .content {
    padding: 8px 12px 80px 12px; /* bottom space for thumb reach */
  }

  /* ---------- 7. Cards: modern mobile cards ---------- */
  .card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    margin-bottom: 14px;
    overflow: hidden;
  }
  .card-header {
    padding: 13px 15px;
    border-bottom: 1px solid #eef1f5;
  }
  .card-header .card-title {
    font-size: 15px;
    font-weight: 700;
  }
  .card-body {
    padding: 14px;
  }
  .card-footer {
    padding: 12px 14px;
    background: #fafbfc;
  }

  /* ---------- 8. Dashboard KPI boxes: 2-per-row grid ---------- */
  .small-box {
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
  }
  .small-box .inner {
    padding: 14px 12px;
  }
  .small-box .inner h3 {
    font-size: 19px;
    font-weight: 800;
    margin-bottom: 2px;
    /* NEVER truncate money: wrap instead of "PKR 59..." */
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.25;
  }
  .small-box .inner p {
    font-size: 12px;
    margin: 0;
    opacity: 0.9;
    /* NEVER truncate labels: wrap to 2 lines instead of cutting */
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    line-height: 1.35;
  }
  .small-box .icon {
    font-size: 56px;
    top: 6px;
    right: 8px;
  }
  .small-box .small-box-footer {
    padding: 8px;
    font-size: 12px;
  }

  /* ---------- 9. Tables: smooth horizontal scroll ---------- */
  .table-responsive {
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #eef1f5;
    margin-bottom: 14px;
    background: #fff;
  }
  .table {
    margin-bottom: 0;
  }
  .table thead th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    white-space: nowrap;
    padding: 11px 10px;
    background: #f8fafc;
    border-bottom: 2px solid #e8edf2;
    position: sticky;
    top: 0;
    z-index: 2;
  }
  .table tbody td {
    font-size: 13.5px;
    padding: 11px 10px;
    vertical-align: middle;
    border-top: 1px solid #f1f4f8;
  }
  .table tbody tr:active {
    background: #f0f7ff;
  }
  /* Row action buttons: tappable */
  .table .btn-sm {
    min-width: 38px;
    min-height: 38px;
    padding: 6px 10px;
    margin: 1px;
  }

  /* ---------- 10. DataTables: stacked, thumb-friendly ---------- */
  .dataTables_wrapper .row {
    margin: 0;
  }
  .dataTables_wrapper .col-sm-12 {
    padding: 0;
  }
  .dataTables_length,
  .dataTables_filter,
  .dataTables_info,
  .dataTables_paginate {
    text-align: left !important;
    padding: 8px 12px;
  }
  .dataTables_filter label {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    font-weight: 600;
  }
  .dataTables_filter input {
    flex: 1;
    min-height: 42px;
    border-radius: 10px;
    margin: 0 !important;
  }
  .dataTables_length select {
    min-height: 42px;
    border-radius: 10px;
  }
  .dataTables_paginate {
    text-align: center !important;
    padding: 12px;
  }
  .dataTables_paginate .paginate_button {
    min-width: 42px !important;
    min-height: 42px !important;
    line-height: 42px !important;
    padding: 0 10px !important;
    margin: 2px !important;
    border-radius: 10px !important;
    font-size: 14px;
  }

  /* ---------- 11. Forms: stacked, large, thumb-friendly ---------- */
  .form-group {
    margin-bottom: 14px;
  }
  label {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #334155;
    display: block;
  }
  .form-control,
  .custom-select,
  select.form-control,
  input[type="text"].form-control,
  input[type="number"].form-control,
  input[type="date"].form-control,
  input[type="tel"].form-control,
  textarea.form-control {
    min-height: 46px;
    font-size: 16px; /* prevents iOS auto-zoom */
    border-radius: 10px;
    border: 1.5px solid #dbe2ea;
    padding: 10px 14px;
    background: #fff;
  }
  .form-control:focus,
  .custom-select:focus {
    border-color: #22D3EE;
    box-shadow: 0 0 0 3px rgba(34,211,238,0.15);
  }
  textarea.form-control {
    min-height: 90px;
  }
  /* Select2 dropdowns */
  .select2-container .select2-selection--single {
    min-height: 46px !important;
    border-radius: 10px !important;
    border: 1.5px solid #dbe2ea !important;
  }
  .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 44px !important;
    font-size: 16px;
  }
  .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 44px !important;
  }
  /* Checkboxes & radios: bigger hit area */
  .form-check {
    padding: 10px 0 10px 34px;
    min-height: 44px;
  }
  .form-check-input {
    width: 22px;
    height: 22px;
    margin-left: -34px;
    margin-top: 0;
  }
  .form-check-label {
    font-size: 15px;
    line-height: 22px;
  }

  /* ---------- 12. Buttons: thumb-sized ---------- */
  .btn {
    min-height: 46px;
    padding: 11px 18px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 10px;
  }
  .btn-sm {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 14px;
    font-size: 14px;
    border-radius: 9px;
  }
  .btn-lg {
    min-height: 52px;
    font-size: 16px;
  }
  .btn-block {
    border-radius: 12px;
  }
  /* Button groups: wrap nicely */
  .btn-group {
    flex-wrap: wrap;
    gap: 6px;
  }
  .btn-group .btn {
    border-radius: 9px !important;
    margin: 0;
  }

  /* ---------- 13. Filter rows: stack vertically ---------- */
  .card-body .row > [class*="col-md-"],
  .card-body .row > [class*="col-sm-"],
  .card-body .row > [class*="col-lg-"] {
    margin-bottom: 12px;
  }
  .card-body .row > [class*="col-md-"]:last-child,
  .card-body .row > [class*="col-sm-"]:last-child,
  .card-body .row > [class*="col-lg-"]:last-child {
    margin-bottom: 0;
  }

  /* ---------- 14. Modals: near-full-screen sheets ---------- */
  .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }
  .modal-content {
    border: none;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  }
  .modal-header {
    padding: 15px 18px 12px 18px;
    border-bottom: 1px solid #eef1f5;
  }
  .modal-header .modal-title {
    font-size: 16px;
    font-weight: 700;
  }
  .modal-header .close {
    min-width: 40px;
    min-height: 40px;
    font-size: 24px;
    padding: 0;
    margin: -8px -8px -8px auto;
  }
  .modal-body {
    padding: 16px 18px;
    max-height: 70vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .modal-footer {
    padding: 12px 18px 16px 18px;
    border-top: 1px solid #eef1f5;
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-footer .btn {
    flex: 1;
    margin: 0;
  }

  /* ---------- 15. Alerts & callouts ---------- */
  .alert {
    border: none;
    border-radius: 12px;
    font-size: 13.5px;
    padding: 12px 14px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  }
  .callout {
    border-radius: 12px;
    padding: 12px 14px;
  }

  /* ---------- 16. Login page: modern centered card ---------- */
  .login-page, .register-page {
    padding: 16px;
  }
  .login-box, .register-box {
    width: 100%;
    max-width: 400px;
    margin: 24px auto;
  }
  .login-logo, .register-logo {
    font-size: 28px;
    margin-bottom: 18px;
  }
  .login-card-body, .register-card-body {
    border-radius: 20px;
    padding: 28px 22px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  }
  .login-box-msg, .register-box-msg {
    font-size: 15px;
    padding-bottom: 16px;
  }

  /* ---------- 17. Pagination & misc ---------- */
  .pagination .page-link {
    min-width: 42px;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    border-radius: 10px;
    margin: 0 2px;
  }

  /* Info boxes */
  .info-box {
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    margin-bottom: 12px;
    padding: 12px;
  }

  /* ---------- 17b. CARD TABLES: rows become cards, no sideways scroll ---------- */
  .rhn-card-table thead {
    display: none !important;
  }
  .rhn-card-table,
  .rhn-card-table tbody {
    display: block !important;
    width: 100% !important;
  }
  .rhn-card-table tbody tr {
    display: block !important;
    background: #fff;
    border-radius: 14px;
    margin-bottom: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.07);
    border: 1px solid #eef1f5;
    padding: 6px 0;
    overflow: hidden;
  }
  .rhn-card-table tbody td {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 10px 14px !important;
    border: none !important;
    border-bottom: 1px solid #f1f4f8 !important;
    font-size: 14px;
    /* NEVER hide cell content: wrap long values instead of cutting */
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .rhn-card-table tbody td:last-child {
    border-bottom: none !important;
  }
  .rhn-card-table tbody td::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #64748b;
    margin-bottom: 3px;
    overflow-wrap: anywhere;
  }
  /* The value: full width, wrap freely, never truncate.
     Applies to .rhn-val wrapper AND everything inside it (links, badges,
     buttons, bold text) so no content type can escape wrapping. */
  .rhn-card-table tbody td > .rhn-val,
  .rhn-card-table tbody td > * {
    display: block !important;
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
  .rhn-card-table tbody td .rhn-val *,
  .rhn-card-table tbody td > * * {
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    white-space: normal !important;
    max-width: 100% !important;
  }
  /* Action buttons: stack vertically, full width */
  .rhn-card-table tbody td .rhn-val .btn,
  .rhn-card-table tbody td > * .btn {
    display: inline-block !important;
    margin: 2px 4px 2px 0 !important;
    white-space: normal !important;
  }
  /* Action buttons cell: stack buttons nicely */
  .rhn-card-table tbody td:last-child {
    flex-wrap: wrap;
  }
  /* Remove the old table-responsive scroll container styling for card tables */
  .table-responsive:has(.rhn-card-table) {
    border: none;
    background: transparent;
    overflow: visible;
  }

  /* ---------- 17c. GLOBAL: never truncate user data on mobile ----------
     Applies to every card, box, and info area on every screen.
     Long text wraps — it is never cut with "..." */
  .card-body, .card-title,
  .info-box-content, .info-box-text, .info-box-number,
  .small-box .inner,
  .callout, .alert,
  .rhn-card-table tbody td {
    overflow-wrap: anywhere;
  }
  .card-title,
  .info-box-text, .info-box-number,
  .small-box .inner h3, .small-box .inner p {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }

  /* Description lists */
  dl.row dt, dl.row dd {
    margin-bottom: 8px;
  }

  /* Print/report pages: keep readable */
  .invoice {
    padding: 12px;
  }
}

/* ---------- 18. Small phones: tighter ---------- */
@media (max-width: 576px) {
  .small-box .inner h3 { font-size: 18px; }
  .small-box .inner p { font-size: 11px; }
  .content-header h1 { font-size: 17px; }
  .card-body { padding: 12px; }
  .btn { font-size: 14px; }
  .table thead th { font-size: 11px; padding: 9px 8px; }
  .table tbody td { font-size: 13px; padding: 9px 8px; }
}

/* ---------- 19. Rahnivo brand ---------- */
:root {
  --rahnivo-navy: #0A1628;
  --rahnivo-cyan: #22D3EE;
}
.main-header.navbar {
  border-bottom: 2px solid var(--rahnivo-cyan);
}
.main-sidebar {
  background-color: var(--rahnivo-navy) !important;
}
.nav-sidebar .nav-link {
  border-radius: 10px;
  margin: 1px 8px;
  padding: 11px 14px;
  font-size: 14px;
}
.nav-sidebar .nav-link.active {
  background-color: var(--rahnivo-cyan) !important;
  color: var(--rahnivo-navy) !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(34,211,238,0.35);
}
.btn-primary {
  background-color: #0ea5c4;
  border-color: #0ea5c4;
  font-weight: 600;
}
.btn-primary:hover, .btn-primary:active {
  background-color: #0b8ba6 !important;
  border-color: #0b8ba6 !important;
}
.card-primary.card-outline {
  border-top: 3px solid var(--rahnivo-cyan);
}
