/*
 * App-like layout for small screens (< 768px).
 * Desktop / tablet keeps the normal website layout: every rule below is
 * scoped to the media query, and the app bars use .d-md-none in markup.
 */
:root {
  --app-primary: #1abc9c;
  --app-dark: #2c3e50;
  --app-bg: #f2f4f7;
  --app-card: #ffffff;
  --app-muted: #8a94a6;
  --app-topbar-h: 56px;
  --app-tabbar-h: 62px;
  --app-radius: 16px;
}

@media (max-width: 767.98px) {

  /* ---------- Type scale: follows screen width (13px @ 340px → 15px @ 400px+) ---------- */
  html {
    font-size: clamp(13px, 3.75vw, 15px);
  }

  /* the template uses fixed px sizes; switch them to rem so they scale too */
  body.app-shell {
    --h1-font-size: 1.6rem;
    --h2-font-size: 1.4rem;
    --h3-font-size: 1.25rem;
    --h4-font-size: 1.15rem;
    --h5-font-size: 1.05rem;
    --h6-font-size: 1rem;
    --p-font-size: 1rem;
    --btn-font-size: 1rem;
    --copyright-font-size: 0.8rem;
    font-size: 1rem;
  }

  body.app-shell h1 { font-size: var(--h1-font-size); }
  body.app-shell h2 { font-size: var(--h2-font-size); }
  body.app-shell h3 { font-size: var(--h3-font-size); }
  body.app-shell h4 { font-size: var(--h4-font-size); }
  body.app-shell h5 { font-size: var(--h5-font-size); }
  body.app-shell h6 { font-size: var(--h6-font-size); }

  /* ---------- Shell ---------- */
  /* fill the screen so short pages keep the copyright just above the tab bar */
  body.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--app-bg);
    padding-top: calc(var(--app-topbar-h) + env(safe-area-inset-top));
    padding-bottom: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom));
    -webkit-tap-highlight-color: transparent;
  }

  body.app-shell #mainNav,
  body.app-shell #nav-footer11,
  body.app-shell .footer,
  body.app-shell .app-hide-mobile {
    display: none !important;
  }

  /* ---------- Top bar ---------- */
  .app-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    display: flex;
    align-items: center;
    height: calc(var(--app-topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 4px 0;
    background: var(--app-dark);
    color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .app-topbar-title {
    flex: 1;
    min-width: 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .app-topbar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    color: #fff;
    font-size: 1.15rem;
    text-decoration: none;
  }

  a.app-topbar-btn:active {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
  }

  /* ---------- Bottom tab bar ---------- */
  .app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    height: calc(var(--app-tabbar-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--app-card);
    border-top: 1px solid #e3e6ec;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
  }

  .app-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--app-muted);
    font-size: 0.68rem;
    line-height: 1;
    text-decoration: none;
  }

  .app-tab i {
    font-size: 1.25rem;
  }

  .app-tab.active,
  .app-tab:hover,
  .app-tab:focus {
    color: var(--app-primary);
    text-decoration: none;
  }

  .app-tab.active i {
    transform: translateY(-1px);
  }

  /* ---------- Page area ---------- */
  body.app-shell .masthead {
    background: var(--app-bg) !important;
    color: #212529 !important;
    padding: 12px 0 16px;
  }

  body.app-shell .masthead .page-section {
    padding: 0;
  }

  body.app-shell .container {
    padding-left: 12px;
    padding-right: 12px;
  }

  /* the top bar already shows the page title */
  body.app-shell .masthead .page-section-heading,
  body.app-shell .masthead .divider-custom {
    display: none;
  }

  body.app-shell .masthead h1.h3 {
    margin: 16px 0 8px !important;
    font-size: 1.1rem;
    color: var(--app-dark) !important;
  }

  body.app-shell .masthead img[src$="r4.png"]:not(.img-fluid) {
    max-height: 140px;
    object-fit: contain;
  }

  body.app-shell .custom-block,
  body.app-shell .masthead .card {
    border-radius: var(--app-radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06) !important;
  }

  body.app-shell .custom-block {
    padding: 16px;
  }

  body.app-shell .masthead .card.my-5 {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
  }

  body.app-shell .masthead .p-5 {
    padding: 1.25rem !important;
  }

  body.app-shell .table {
    font-size: 0.85rem;
  }

  body.app-shell .btn {
    border-radius: 12px;
  }

  body.app-shell .form-control {
    min-height: 44px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* ---------- Home: profile card ---------- */
  body.app-shell .content-to-disable > .row {
    margin-left: 0;
    margin-right: 0;
  }

  body.app-shell .app-profile {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 14px;
    margin-bottom: 16px !important;
    padding: 16px;
    border-radius: var(--app-radius);
    background: linear-gradient(135deg, var(--app-primary) 0%, #16a085 100%);
    color: #fff;
    text-align: left;
    box-shadow: 0 6px 16px rgba(26, 188, 156, 0.3);
  }

  body.app-shell .app-profile br,
  body.app-shell .app-profile hr {
    display: none;
  }

  body.app-shell .app-profile .masthead-avatar {
    width: 64px;
    height: 64px;
    margin: 0 !important;
    padding: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    order: 0;
  }

  body.app-shell .app-profile h4 {
    flex: 1;
    min-width: 0;
    font-size: 1.05rem;
    order: 1;
  }

  body.app-shell .app-profile h5 {
    flex-basis: 100%;
    font-size: 0.85rem;
    font-weight: 400;
    opacity: 0.95;
    order: 2;
  }

  body.app-shell .app-profile #act_status {
    flex-basis: 100%;
    margin: 8px 0 0;
    order: 3;
  }

  body.app-shell .app-profile #act_status .alert {
    margin: 0;
    padding: 8px 12px;
    border: 0;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
  }

  /* ---------- Home: menu grid ---------- */
  body.app-shell .app-menu {
    padding: 0;
  }

  body.app-shell .app-menu .custom-block-overlay {
    min-height: 0;
    margin: 0 !important;
    padding: 0;
    background: transparent;
    box-shadow: none !important;
    font-size: inherit;
  }

  body.app-shell .app-menu .row {
    margin: 0 -6px !important;
    row-gap: 12px;
  }

  body.app-shell .app-menu .row > [class*="col-"] {
    display: flex;
    flex-direction: column;
    margin-bottom: 0 !important;
    padding: 0 6px;
    border-radius: var(--app-radius);
    background: var(--app-card);
    background-clip: content-box;
    box-shadow: none;
  }

  body.app-shell .app-menu .row > [class*="col-"] {
    transition: transform 0.1s ease;
  }

  body.app-shell .app-menu .row > [class*="col-"]:active {
    transform: scale(0.96);
  }

  body.app-shell .app-menu .portfolio-item {
    max-width: none;
    margin: 12px 12px 0;
    border-radius: 12px;
  }

  body.app-shell .app-menu .portfolio-item-caption,
  body.app-shell .app-menu .loader-container {
    display: none !important;
  }

  body.app-shell .app-menu .custom-btn {
    margin: 8px 8px 12px !important;
    padding: 4px;
    background: transparent;
    border: 0;
    color: var(--app-dark);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: normal;
  }

  /* ---------- News ---------- */
  body.app-shell #about {
    background: var(--app-bg) !important;
    color: #212529 !important;
    padding: 0 0 16px;
  }

  body.app-shell #about .page-section-heading {
    color: var(--app-dark) !important;
    font-size: 1.1rem;
    line-height: 1.4;
    text-align: left !important;
    margin-bottom: 12px;
  }

  body.app-shell #about .divider-custom {
    display: none;
  }

  body.app-shell #about .card {
    border-radius: var(--app-radius);
    border: 0;
  }

  body.app-shell #about .btn-outline-light {
    width: 100%;
    color: var(--app-muted);
    border-color: #dfe3ea;
    background: var(--app-card);
    font-size: 0.95rem;
    padding: 14px;
  }

  /* ---------- Copyright ---------- */
  body.app-shell .copyright {
    margin-top: auto;
    padding: 8px 0 !important;
    background: transparent;
    color: var(--app-muted) !important;
    font-size: 0.75rem;
  }

  body.app-shell .copyright a {
    color: var(--app-muted);
  }

  /* ---------- Login ---------- */
  body.app-login {
    min-height: 100vh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }

  body.app-login .card.my-5 {
    margin: 24px 0 !important;
    border-radius: 20px;
  }

  body.app-login .p-5 {
    padding: 24px !important;
  }

  body.app-login .form-control-user {
    min-height: 48px;
    font-size: 16px;
  }

  body.app-login .btn-user {
    min-height: 48px;
    font-size: 1rem;
  }
}
