/* Tablet & HP — dimuat setelah file bagian */

/* ================= Tablet (≤ 960px) ================= */
@media (max-width: 960px) {
  .tabs {
    margin-left: 8px;
  }
  .admin {
    padding: 16px 20px 40px;
  }
  .app {
    grid-template-columns: 1fr;
    grid-template-areas: "board" "mine";
    grid-template-rows: auto;
    padding: 16px 20px 40px;
  }
  .board {
    min-width: 420px;
  }
  .days {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow: visible;
  }
  .d {
    min-width: 0;
  }
  .note {
    display: none;
  }
  .selection-help {
    font-size: 11.5px;
    line-height: 1.45;
  }

  /* Form jadi panel yang muncul dari bawah */
  .side {
    position: fixed;
    z-index: 30;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0 auto;
    width: min(560px, 100%);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--paper);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -8px 32px var(--shadow);
    padding: 18px 20px calc(20px + env(safe-area-inset-bottom));
    transform: translateY(105%);
    visibility: hidden;
    transition:
      transform 0.22s ease,
      visibility 0s 0.22s;
  }
  .side.open {
    transform: none;
    visibility: visible;
    transition: transform 0.22s ease;
  }
  .close {
    flex: none;
  }
  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 29;
    background: var(--scrim);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
  }
  .backdrop.open {
    opacity: 1;
    pointer-events: auto;
  }
  .mine-list {
    margin-top: 24px;
  }
  .mine-list h3 {
    font-size: 13px;
  }
  .mine-list button {
    font-size: 13px;
    padding: 8px 0;
  }
  .mine-list .r {
    font-size: 12px;
  }
}
@media (min-width: 961px) {
  .new-btn {
    display: none;
  }
  .app.side-closed {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "board" "mine";
    grid-template-rows: auto;
  }
  .app.side-closed .side {
    display: none;
  }
  .app.side-closed .new-btn,
  body.guest:not(.login-open) .new-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }
  body.guest:not(.login-open) .app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "board" "mine";
  }
  body.guest:not(.login-open) .side {
    display: none;
  }
  body.guest.login-open .login-box .close {
    display: none;
  }
}

/* ================= Tablet landscape ================= */
@media (min-width: 601px) and (max-width: 1180px) and (orientation: landscape) {
  :root {
    --row: 30px;
    --time-col: 48px;
  }
  body {
    font-size: 14px;
  }
  .top {
    gap: 10px;
    padding-right: 18px;
    padding-left: 18px;
  }
  .brand {
    gap: 9px;
  }
  .brand-text {
    padding-left: 9px;
  }
  .tabs {
    gap: 2px;
    margin-left: 12px;
  }
  .tabs button {
    padding: 6px 8px;
    font-size: 13px;
  }
  .theme-toggle {
    padding-right: 8px;
    padding-left: 8px;
  }
  .app {
    gap: 0 20px;
    padding: 16px 18px 32px;
  }
  .daybar {
    gap: 7px;
    margin-bottom: 10px;
  }
  .daybar h1 {
    font-size: 19px;
  }
  .strip {
    gap: 6px;
    margin-bottom: 10px;
  }
  .strip .step,
  .d {
    height: 46px;
  }
  .days {
    gap: 3px;
  }
  .bhead div {
    padding: 7px 6px;
    font-size: 12px;
  }
  .bhead .hs {
    font-size: 11px;
  }
  .bk {
    padding-right: 4px;
    padding-left: 4px;
    font-size: 11px;
  }
  .selection-help {
    font-size: 11px;
  }
  .side {
    max-height: 84vh;
    max-height: 84dvh;
  }
}

/* ================= HP (≤ 600px) ================= */
@media (max-width: 600px) {
  :root {
    --row: 28px;
    --time-col: 36px;
  }
  .top {
    gap: 6px;
    padding: 8px 10px;
    padding-top: max(8px, env(safe-area-inset-top));
  }
  .brand {
    gap: 7px;
    flex: 1;
    min-width: 0;
  }
  .brand img {
    height: 23px;
  }
  .brand-text {
    padding-left: 7px;
  }
  .brand-text b {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-text small {
    display: none;
  }
  .theme-toggle {
    width: 34px;
    min-width: 34px;
    padding: 4px;
  }
  .theme-toggle span:last-child {
    display: none;
  }
  .top .user {
    gap: 0;
  }
  .top .user .link {
    padding: 6px 9px;
    font-size: 12px;
  }
  .app {
    padding: 10px 10px 24px;
  }

  .daybar {
    gap: 6px;
    margin-bottom: 8px;
  }
  .daybar h1 {
    font-size: 16px;
    width: 100%;
    margin: 0;
  }
  .daybar .new-btn {
    height: 32px;
    padding: 0 10px;
    font-size: 12px;
  }
  .daybar .new-btn {
    margin-left: auto;
    text-align: center;
  }
  .navbtns {
    gap: 6px;
  }
  .today,
  .jump {
    height: 32px;
  }
  .today {
    padding: 0 9px;
    font-size: 12px;
  }
  .jump {
    padding: 0 6px;
    font-size: 12px;
  }
  .strip {
    gap: 4px;
    margin-bottom: 8px;
  }
  .strip .step,
  .d {
    height: 40px;
  }
  .strip .step {
    width: 32px;
  }
  .days {
    gap: 3px;
  }
  .d .dw {
    font-size: 10px;
  }
  .d .dn {
    font-size: 13px;
  }

  /* Geser horizontal hanya kalau ruangannya memang banyak */
  .board {
    min-width: max(100%, calc(var(--time-col) + var(--rooms) * 64px));
  }
  .bhead div {
    flex-direction: column;
    padding: 5px 2px;
    font-size: 9.5px;
    line-height: 1.2;
    text-align: center;
    white-space: normal;
    overflow-wrap: anywhere;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
  }
  .bhead .full {
    display: none;
  }
  .bhead .short {
    display: inline;
  }
  .times span {
    right: 4px;
    font-size: 10px;
  }
  .bk {
    left: 2px;
    right: 2px;
    padding: 2px 4px;
    font-size: 10.5px;
    gap: 1px;
  }
  .bk .l1 {
    gap: 3px;
  }
  .bk .te,
  .bk .p {
    display: none;
  }
  .bk .nm {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .sel {
    left: 2px;
    right: 2px;
    padding: 2px 4px;
    font-size: 10.5px;
  }

  .bhead .hs {
    font-size: 0;
    margin-top: 2px;
  }
  .bhead .hs::before {
    margin: 0;
    width: 8px;
    height: 8px;
  }
  .selection-help {
    font-size: 11px;
    line-height: 1.4;
  }
  /* Admin di HP: cukup logo + menu dropdown */
  .top.has-tabs .brand {
    flex: none;
  }
  .top.has-tabs .brand-text,
  .top.has-tabs .user strong {
    display: none;
  }
  .admin {
    padding: 14px 12px 32px;
  }
  .admin-bar h1 {
    font-size: 18px;
  }

  /* Reservasi saya: lebih ringkas */
  .mine-list {
    margin-top: 18px;
    padding-top: 12px;
  }
  .mine-list h3 {
    font-size: 12px;
    margin-bottom: 2px;
  }
  .mine-list ul {
    max-height: min(34vh, 300px);
  }
  .mine-list button {
    padding: 7px 0;
    font-size: 12.5px;
    line-height: 1.35;
  }
  .mine-list .w {
    font-weight: 500;
  }
  .mine-list .r {
    font-size: 11.5px;
  }
  .empty {
    font-size: 12px;
  }

  /* Auto-zoom iPhone dicegah lewat meta viewport di index.html */
  .field input,
  .field select,
  .field textarea {
    font-size: 13px;
    padding: 8px 9px;
  }
  .field label {
    font-size: 11.5px;
    margin-bottom: 3px;
  }

  /* Panel bawah (masuk / reservasi / detail): ±3/4 ukuran */
  .side {
    padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  }
  .side-head {
    padding-top: 6px;
  }
  .side-head::before {
    width: 32px;
    height: 4px;
  }
  .side h2 {
    font-size: 14px;
  }
  .close {
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11.5px;
  }
  .close::before {
    width: 9px;
    height: 9px;
  }
  .side .field {
    margin-top: 10px;
  }
  .side .pair {
    gap: 8px;
  }
  .side .field textarea {
    min-height: 46px;
  }
  .side .primary {
    margin-top: 12px;
    padding: 9px;
    font-size: 13px;
  }
  .login-box p,
  .side .hint-sm {
    font-size: 11.5px;
  }
  .side .pending,
  .side .msg,
  .side .owner {
    font-size: 12px;
  }
  .password-toggle {
    width: 30px;
    height: 30px;
  }
  .password-toggle svg {
    width: 16px;
    height: 16px;
  }
  .field .password-control input {
    padding-right: 38px;
  }
  .side .row-actions {
    gap: 8px;
    font-size: 12.5px;
  }
  .side .secondary-btn,
  .side .danger-btn {
    min-height: 34px;
    padding: 6px 10px;
  }
  .booking-details {
    margin: 12px 0 14px;
  }
  .booking-details > div {
    padding: 8px 0;
  }
  .booking-details dt {
    margin-bottom: 2px;
    font-size: 11px;
  }
  .booking-details dd {
    font-size: 13px;
  }
  .side .booking-details + .primary {
    margin-top: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .board,
  .side,
  .backdrop,
  .toast {
    transition: none !important;
  }
}
