/* =========================================================
   1001 Academy Universal Responsive Layer
   Safe override file: desktop / laptop / tablet / phone
   ========================================================= */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

img,
video,
iframe,
canvas,
svg {
  max-width: 100%;
}

img,
video {
  height: auto;
}

button,
.btn,
input,
select,
textarea,
a {
  -webkit-tap-highlight-color: transparent;
}

button,
.btn,
input,
select,
textarea {
  max-width: 100%;
}

/* Prevent random long text, URLs, emails, and table content from breaking pages */
p,
h1,
h2,
h3,
h4,
h5,
h6,
span,
strong,
small,
label,
td,
th,
.notice,
.empty,
.muted {
  overflow-wrap: anywhere;
}

/* Keep main containers clean on large desktop */
.container,
.page-shell,
.section-inner,
.hero-inner,
.catalog-page,
.course-page,
.cart-page,
.account-page,
.payment-result-page,
.my-courses-page,
.learn-page {
  width: min(100% - 40px, 1180px);
  margin-inline: auto;
}

/* Tables must scroll inside their card, not the whole page */
.table-wrap,
.responsive-table-wrap,
.card:has(table),
.ticket-thread,
#cliq-payments-view {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table,
table {
  max-width: 100%;
  border-collapse: collapse;
}

/* Dashboard dynamic tables need a safe minimum width only inside scroll wrapper */
.table-wrap table,
.responsive-table-wrap table,
#cliq-payments-view table {
  min-width: 760px;
}

/* File inputs should not overflow on phones */
input[type="file"] {
  width: 100%;
}

/* CliQ popup baseline safety */
.cliq-modal {
  max-width: 100vw;
}

.cliq-modal-card {
  max-width: min(560px, 94vw);
  max-height: 92dvh;
  overflow-y: auto;
}

/* =========================
   Laptop / small desktop
   ========================= */
@media (max-width: 1280px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 36px, 1120px);
  }

  .hero,
  .section,
  .section-soft,
  .course-hero,
  .catalog-section {
    padding-inline: 18px;
  }

  .course-grid,
  .courses-grid,
  .popular-grid,
  .category-grid,
  .catalog-grid,
  .related-grid {
    gap: 18px;
  }
}

/* =========================
   iPad landscape / tablet
   ========================= */
@media (max-width: 1024px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 32px, 920px);
  }

  .site-header,
  .topbar,
  .navbar,
  .nav-wrap,
  .nav-inner {
    max-width: 100%;
  }

  .site-header .container,
  .topbar .container,
  .nav-wrap,
  .nav-inner {
    flex-wrap: wrap;
    gap: 12px;
  }

  .nav-search {
    flex: 1 1 280px;
    min-width: 220px;
  }

  .nav-links {
    gap: 10px;
    flex-wrap: wrap;
  }

  .hero,
  .hero-grid,
  .hero-inner,
  .course-detail-grid,
  .course-layout,
  .purchase-layout,
  .learn-layout,
  .learning-layout,
  .account-page,
  .account-layout,
  .profile-layout,
  .ticket-grid {
    grid-template-columns: 1fr !important;
  }

  .course-grid,
  .courses-grid,
  .popular-grid,
  .catalog-grid,
  .related-grid,
  .my-courses-grid,
  .category-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .purchase-card,
  .course-sidebar,
  .learn-sidebar,
  .lesson-sidebar {
    position: static !important;
    width: 100%;
    max-width: 100%;
  }

  .course-media,
  .purchase-media,
  .lesson-player,
  .video-shell,
  .learn-video,
  .course-video {
    width: 100%;
    max-width: 100%;
  }

  .course-media img,
  .purchase-media img,
  .course-card img,
  .related-card img {
    width: 100%;
    object-fit: cover;
  }

  /* Dashboard tablet */
  .dashboard-body {
    overflow-x: hidden;
  }

  .dashboard-shell,
  .dashboard-layout,
  .dash-layout,
  .dash-main {
    grid-template-columns: 1fr !important;
    width: 100%;
    max-width: 100%;
  }

  .dashboard-sidebar,
  .dash-sidebar,
  .sidebar {
    position: static !important;
    width: 100%;
    max-width: 100%;
  }

  .dashboard-sidebar nav,
  .dash-sidebar nav,
  .dashboard-nav,
  .dash-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }

  .dashboard-sidebar button,
  .dash-sidebar button,
  .dashboard-nav button,
  .dash-nav button,
  [data-tab] {
    flex: 0 0 auto;
    white-space: nowrap;
  }
}

/* =========================
   iPad portrait / big phone
   ========================= */
@media (max-width: 768px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 28px, 100%);
  }

  body {
    font-size: 15px;
  }

  h1 {
    font-size: clamp(28px, 8vw, 42px) !important;
    line-height: 1.12;
  }

  h2 {
    font-size: clamp(22px, 6vw, 32px) !important;
    line-height: 1.18;
  }

  h3 {
    font-size: clamp(18px, 5vw, 24px) !important;
  }

  .hero,
  .section,
  .section-soft,
  .course-hero,
  .catalog-section,
  .auth-section,
  .account-section {
    padding-block: 32px;
    padding-inline: 14px;
  }

  .hero-actions,
  .course-actions,
  .purchase-actions,
  .auth-actions,
  .cart-item-actions,
  .payment-result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .course-grid,
  .courses-grid,
  .popular-grid,
  .catalog-grid,
  .related-grid,
  .my-courses-grid,
  .category-grid,
  .stat-grid {
    grid-template-columns: 1fr !important;
  }

  .course-card,
  .category,
  .filters,
  .purchase-card,
  .sidebar-note,
  .related-card,
  .auth-card,
  .cart-item,
  .cart-summary,
  .loading-card,
  .empty,
  .account-panel,
  .card {
    max-width: 100%;
  }

  .catalog-toolbar,
  .filters,
  .form-row {
    grid-template-columns: 1fr !important;
    display: grid;
    gap: 12px;
  }

  .field,
  .field input,
  .field select,
  .field textarea,
  form input,
  form select,
  form textarea {
    width: 100%;
  }

  .btn,
  button,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  /* Navbar phone/tablet */
  .site-header,
  .topbar {
    padding-inline: 12px;
  }

  .site-header .container,
  .topbar .container,
  .nav-wrap,
  .nav-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .logo,
  .brand,
  .site-logo {
    flex: 0 0 auto;
    max-width: 170px;
  }

  .logo img,
  .brand img,
  .site-logo img {
    max-height: 42px;
    width: auto;
  }

  .nav-search {
    order: 10;
    flex: 1 1 100%;
    width: 100%;
  }

  .nav-search input {
    width: 100%;
  }

  .nav-links {
    order: 11;
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .nav-links a,
  .nav-category {
    white-space: nowrap;
  }

  /* Course details */
  .purchase-card {
    margin-top: 18px;
  }

  .purchase-card .btn,
  .purchase-card button,
  #cliq-pay-button {
    width: 100%;
  }

  .price,
  .course-price,
  .purchase-price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Cart */
  .cart-item {
    display: grid !important;
    grid-template-columns: 120px 1fr;
    gap: 14px;
    align-items: start;
  }

  .cart-item-image {
    width: 120px;
    max-width: 100%;
  }

  .cart-item-image img {
    width: 120px;
    height: 90px;
    object-fit: cover;
    border-radius: 14px;
  }

  .cart-item-copy {
    min-width: 0;
  }

  .cart-item-actions {
    grid-column: 1 / -1;
    width: 100%;
  }

  .cart-item-actions .btn,
  .cart-item-actions button {
    flex: 1 1 160px;
  }

  /* Learn page */
  .lesson-player,
  .video-shell,
  .learn-video,
  .course-video,
  .lesson-video {
    aspect-ratio: 16 / 9;
    max-height: 60dvh;
  }

  video {
    width: 100%;
    height: auto;
  }

  .learn-list,
  .lesson-list,
  .accordion {
    width: 100%;
  }

  /* Support chat */
  .academy-chat,
  .support-chat,
  .chat-widget,
  .academy-chat-widget,
  #support-chat {
    max-width: min(420px, calc(100vw - 24px));
  }

  .chat-panel,
  .chat-window,
  .academy-chat-panel,
  .support-chat-panel {
    max-width: calc(100vw - 24px);
    max-height: 78dvh;
  }

  /* Dashboard */
  .dash-view,
  .dashboard-view,
  .dashboard-content {
    max-width: 100%;
    overflow-x: hidden;
  }

  .dashboard-sidebar,
  .dash-sidebar {
    border-radius: 18px;
  }

  .table-wrap,
  .responsive-table-wrap,
  #cliq-payments-view {
    border-radius: 16px;
  }

  #cliq-payments-view .btn,
  #cliq-payments-view button {
    min-height: 38px;
    padding-inline: 12px;
  }

  /* CliQ popup */
  .cliq-modal {
    align-items: center;
    padding: 14px;
  }

  .cliq-modal-card {
    width: min(94vw, 560px);
    max-height: 90dvh;
    padding: 20px;
    border-radius: 20px;
  }

  .cliq-info-box div {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .cliq-form input,
  .cliq-form button {
    width: 100%;
  }
}

/* =========================
   Phone
   ========================= */
@media (max-width: 520px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 24px, 100%);
  }

  .hero,
  .section,
  .section-soft,
  .course-hero,
  .catalog-section,
  .auth-section,
  .account-section {
    padding-block: 26px;
    padding-inline: 10px;
  }

  .btn,
  .hero-actions .btn,
  .course-actions .btn,
  .purchase-actions .btn,
  .auth-actions .btn,
  .payment-result-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .course-card,
  .category,
  .filters,
  .purchase-card,
  .related-card,
  .auth-card,
  .cart-item,
  .cart-summary,
  .account-panel,
  .card {
    border-radius: 18px;
  }

  .course-media img,
  .purchase-media img,
  .course-card img,
  .related-card img {
    min-height: 180px;
    max-height: 230px;
    object-fit: cover;
  }

  .catalog-toolbar,
  .filters {
    gap: 10px;
  }

  .logo,
  .brand,
  .site-logo {
    max-width: 145px;
  }

  .logo img,
  .brand img,
  .site-logo img {
    max-height: 36px;
  }

  .profile-dropdown,
  .account-dropdown {
    inset-inline-end: 0;
    max-width: calc(100vw - 24px);
  }

  .cart-item {
    grid-template-columns: 1fr !important;
  }

  .cart-item-image,
  .cart-item-image img {
    width: 100%;
  }

  .cart-item-image img {
    height: 190px;
  }

  .cart-item-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .lesson-player,
  .video-shell,
  .learn-video,
  .course-video,
  .lesson-video {
    max-height: 52dvh;
  }

  .cliq-modal {
    padding: 10px;
    place-items: center;
  }

  .cliq-modal-card {
    width: 94vw;
    max-height: 90dvh;
    padding: 18px;
  }

  .cliq-modal-close {
    top: 10px;
    inset-inline-end: 10px;
  }

  .cliq-modal-card h2 {
    padding-inline-end: 40px;
  }

  .chat-panel,
  .chat-window,
  .academy-chat-panel,
  .support-chat-panel {
    position: fixed !important;
    inset-inline: 12px !important;
    bottom: 82px !important;
    width: auto !important;
    max-width: none !important;
    max-height: 72dvh !important;
  }

  .chat-bubble,
  .academy-chat-bubble,
  .support-chat-bubble {
    bottom: 18px !important;
    inset-inline-end: 16px !important;
  }
}

/* =========================
   Small phone
   ========================= */
@media (max-width: 420px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 20px, 100%);
  }

  body {
    font-size: 14.5px;
  }

  h1 {
    font-size: clamp(25px, 9vw, 34px) !important;
  }

  h2 {
    font-size: clamp(20px, 7vw, 28px) !important;
  }

  .hero,
  .section,
  .section-soft,
  .course-hero,
  .catalog-section,
  .auth-section,
  .account-section {
    padding-block: 22px;
    padding-inline: 8px;
  }

  .course-media img,
  .purchase-media img,
  .course-card img,
  .related-card img {
    min-height: 160px;
    max-height: 210px;
  }

  .btn,
  button,
  input,
  select,
  textarea {
    min-height: 44px;
    font-size: 14px;
  }

  .table-wrap table,
  .responsive-table-wrap table,
  #cliq-payments-view table {
    min-width: 680px;
  }

  .cliq-modal-card {
    width: 95vw;
    padding: 16px;
    border-radius: 18px;
  }

  .cliq-info-box,
  .cliq-instruction {
    font-size: 14px;
  }
}

/* =========================
   Ultra-wide desktop
   ========================= */
@media (min-width: 1536px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 64px, 1240px);
  }
}

@media (min-width: 1920px) {
  .container,
  .page-shell,
  .section-inner,
  .hero-inner,
  .catalog-page,
  .course-page,
  .cart-page,
  .account-page,
  .payment-result-page,
  .my-courses-page,
  .learn-page {
    width: min(100% - 80px, 1320px);
  }
}
