/* Royal Atelier Online — responsive layout fixes (site-side copy only).
   Layout only: no colours, no fonts, no text changes.
   Desktop (>= 1025px) is left exactly as it is.
   Build 246b2 */

/* ===== 1) Tablet band: keep the top bar on one row (no dead band) ===== */
@media (min-width: 768px) and (max-width: 1024px) {
  .top-navbar {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    gap: 10px !important;
    align-items: center !important;
  }
  .top-navbar .global-search {
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  .top-navbar > div:not(.top-right-tools):not(.top-left-tools) {
    flex: 1 1 auto !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }
  .top-navbar > .top-right-tools,
  .top-navbar > .top-left-tools { flex: 0 0 auto !important; }
  #current-user-display { max-width: 160px !important; }
}

/* ===== 2) Phones: data tables stay tables and scroll, instead of
        collapsing into stacked cards with no field labels ===== */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-responsive table { display: table !important; }
  .table-responsive thead { display: table-header-group !important; }
  .table-responsive tbody { display: table-row-group !important; }
  .table-responsive tfoot { display: table-footer-group !important; }
  .table-responsive tr {
    display: table-row !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
  }
  .table-responsive th { display: table-cell !important; }
  .table-responsive td {
    display: table-cell !important;
    padding: 8px 10px !important;
    border-bottom: 1px solid var(--border-color, rgba(0,0,0,.08)) !important;
  }
  .table-responsive td::before { content: none !important; }
}

/* ===== 3) Phones: report filters stack full width, never overflow the card ===== */
@media (max-width: 640px) {
  .rpt168-filters {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .rpt168-filters > * {
    grid-column: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }
  .rpt168-filters .rpt168-dd,
  .rpt168-filters .rpt168-dd-btn { width: 100% !important; max-width: 100% !important; }
  .rpt168-filters input,
  .rpt168-filters select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
  .rpt168-actions {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
  }
  .rpt168-actions button { flex: 1 1 auto !important; width: auto !important; min-width: 0 !important; }
}

/* ===== 4) Report tables: always scroll inside their own card ===== */
@media (max-width: 1024px) {
  #report-output .rpt168-table-wrap > div,
  #r263-seller-panel > div {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  #report-output .rpt168-table-wrap > div > table,
  #r263-seller-panel table { min-width: 0 !important; }
}


/* ===== 5) Wide data tables scroll inside their own card instead of being cut ===== */
@media (max-width: 1024px) {
  #main-content .table-responsive, #main-content .panel .table-responsive { overflow-x: auto !important; overflow-y: visible !important; -webkit-overflow-scrolling: touch; max-width: 100%; }
}

/* ===== 6) Report tables (sales / bookings / etc.) keep header + real table rows at phone and tablet widths ===== */
@media (max-width: 768px) {
  #report-output table:not(#r263-seller-panel table) { display: table !important; width: 100% !important; min-width: 0 !important; }
  #report-output table:not(#r263-seller-panel table) thead { display: table-header-group !important; }
  #report-output table:not(#r263-seller-panel table) tbody { display: table-row-group !important; }
  #report-output table:not(#r263-seller-panel table) tr { display: table-row !important; box-shadow: none !important; border-radius: 0 !important; margin: 0 !important; background: transparent !important; }
  #report-output table:not(#r263-seller-panel table) th,
  #report-output table:not(#r263-seller-panel table) td { display: table-cell !important; white-space: nowrap; }
  #report-output table:not(#r263-seller-panel table) td::before { content: none !important; }
}

/* ===== 7) Commission summary: labelled rows on phones so the % input stays inside the card ===== */
@media (max-width: 640px) {
  #r263-seller-panel table, #r263-seller-panel tbody { display: block !important; width: 100% !important; min-width: 0 !important; }
  #r263-seller-panel thead { display: none !important; }
  #r263-seller-panel tr { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px !important; box-sizing: border-box; width: 100%; }
  #r263-seller-panel td { display: block !important; padding: 0 !important; border: 0 !important; white-space: normal !important; min-width: 0; }
  #r263-seller-panel td:nth-child(1) { grid-column: 1 / -1; font-weight: 700; }
  #r263-seller-panel td::before { display: block !important; font-size: 11px; opacity: .7; margin-bottom: 2px; }
  #r263-seller-panel td:nth-child(2)::before { content: "عدد العمليات" !important; }
  #r263-seller-panel td:nth-child(3)::before { content: "إجمالي المبيعات" !important; }
  #r263-seller-panel td:nth-child(4)::before { content: "المدفوع" !important; }
  #r263-seller-panel td:nth-child(5)::before { content: "نسبة العمولة %" !important; }
  #r263-seller-panel td:nth-child(6)::before { content: "قيمة العمولة" !important; }
  #r263-seller-panel td:nth-child(7)::before { content: none !important; }
  #r263-seller-panel td:nth-child(7) { grid-column: 1 / -1; }
  #r263-seller-panel input.r263-pct { width: 100% !important; max-width: 120px; box-sizing: border-box; }
}

/* ===== 8) Bookings table: no text wrapped or broken inside a cell, compact at tablet widths ===== */
@media (min-width: 620px) and (max-width: 1100px) {
  #reservations-main-table { min-width: 0 !important; }
  #reservations-main-table th, #reservations-main-table td { white-space: nowrap !important; word-break: normal !important; overflow-wrap: normal !important; padding: 6px 5px !important; font-size: 12px !important; }
}
@media (max-width: 619px) {
  #reservations-main-table th, #reservations-main-table td { white-space: nowrap !important; word-break: normal !important; overflow-wrap: normal !important; }
}

/* ===== 9) Dashboard title: not flush against the card edge, no clipped ascenders ===== */
#dashboard > h2:first-child { padding: 10px 10px 4px !important; line-height: 1.5 !important; box-sizing: border-box; }

/* ===== 10) Dashboard KPI cards: balanced 4 + 4 on laptop widths instead of 7 + 1 ===== */
@media (min-width: 1025px) and (max-width: 1599px) {
  #main-content #dashboard .dashboard-cards { grid-template-columns: repeat(4, 1fr) !important; }
}

/* 11. statistics custom date range: keep both date fields inside the card on phones */
@media (max-width:640px){
  #main-content #stats .r67-tb2 .r67-tb-range{flex-wrap:wrap !important;max-width:100% !important;gap:6px !important;white-space:normal !important}
  #main-content #stats .r67-tb2 .r67-tb-range > input.royal-dmy{width:130px !important;min-width:0 !important;max-width:100% !important;flex:1 1 130px !important}
}

/* 12. Button labels stay on one line: no mid-word splitting */
@media (min-width: 641px) {
  #main-content button, #main-content .btn-neon {
    white-space: nowrap !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
  }
}
#r263-seller-panel td:last-child { white-space: nowrap !important; }
#r263-seller-panel .r263-confirm {
  white-space: nowrap !important;
  word-break: normal !important;
  overflow-wrap: normal !important;
  font-size: 12px !important;
  padding: 7px 10px !important;
  line-height: 1.2 !important;
}

/* 13. Commission summary at tablet widths: compact cells so the nowrap confirm button fits without sideways scroll */
@media (min-width: 641px) and (max-width: 1100px) {
  #r263-seller-panel th, #r263-seller-panel td { padding: 7px 6px !important; font-size: 12px !important; }
  #r263-seller-panel input.r263-pct { width: 70px !important; }
  #r263-seller-panel .r263-confirm { font-size: 11.5px !important; padding: 6px 8px !important; }
}

/* 14. No value clipped inside a column, and a light fade at the scroll edge so cut columns read as "more to scroll" */
@media (max-width: 1024px) {
  #main-content .table-responsive {
    background-image: linear-gradient(to right, rgba(0,0,0,.14), rgba(0,0,0,0) 26px);
    background-repeat: no-repeat;
    background-position: left top;
    background-size: 26px 100%;
  }
  body.dark #main-content .table-responsive,
  [data-theme="dark"] #main-content .table-responsive {
    background-image: linear-gradient(to right, rgba(255,255,255,.16), rgba(255,255,255,0) 26px);
  }
  #main-content .table-responsive table { table-layout: auto !important; }
  #main-content .table-responsive th,
  #main-content .table-responsive td {
    min-width: max-content !important;
    overflow: visible !important;
    text-overflow: clip !important;
  }
}

/* 15a. Dress price stays on one line in the narrow tablet cards */
@media (min-width: 641px) and (max-width: 1100px) {
  #main-content .dress-item .dress-price { white-space: nowrap !important; font-size: 13.5px !important; }
}
/* 15b. Seller summary on phones: label pseudo-elements no longer force a fixed 100px width, so the inner scrollbar only shows when content really overflows */
@media (max-width: 640px) {
  #r263-seller-panel td::before { width: auto !important; min-width: 0 !important; max-width: 100% !important; }
}

/* 16. Sort arrows never print */
@media print { .r329-sort { display: none !important; } }
