/* ==========================================================================
   Tampilan desktop portal pegawai (>= 1024px)
   Mobile tetap memakai shell + dock bawah dari app.css.
   ========================================================================== */

.app-sidebar {
  display: none;
}

@media (min-width: 1024px) {
  html:has(body.app-body),
  body.app-body {
    height: 100%;
    overflow: hidden;
    background: #e9f0f3;
  }

  body.app-body {
    display: block;
    padding: 0;
  }

  /* Shell penuh: sidebar kiri + area konten */
  .app-phone {
    display: grid;
    grid-template-columns: 16.5rem minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    width: 100%;
    height: 100vh;
    height: 100dvh;
    flex: none;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    background:
      radial-gradient(900px 420px at 100% 0%, rgba(61, 168, 194, 0.1), transparent 60%),
      #eef4f7;
    transform: none;
  }

  .app-phone > .dashboard-header,
  .app-phone > .app-topbar {
    grid-column: 2;
    grid-row: 1;
  }

  .app-phone > main {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
    max-width: 1180px !important;
    margin-inline: auto !important;
    padding: 1.75rem clamp(1.5rem, 2.4vw, 2.5rem) 3rem !important;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-phone > .app-sidebar {
    grid-column: 1;
    grid-row: 1 / -1;
  }

  .app-phone > .app-dock {
    display: none;
  }

  .app-phone > .login-screen {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
    width: 100%;
    height: 100%;
    overflow-y: auto;
  }

  /* Saat admin masuk sebagai pegawai, banner tetap di atas semua kolom. */
  .app-phone > .impersonation-bar {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .app-phone:has(> .impersonation-bar) {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  .app-phone:has(> .impersonation-bar) > .dashboard-header,
  .app-phone:has(> .impersonation-bar) > .app-topbar {
    grid-row: 2;
  }

  .app-phone:has(> .impersonation-bar) > main {
    grid-row: 3;
  }

  .app-phone:has(> .impersonation-bar) > .app-sidebar {
    grid-row: 2 / -1;
  }

  /* Halaman login memakai seluruh layar tanpa sidebar. */
  .app-phone:has(> .login-screen) {
    display: block;
    background:
      radial-gradient(900px 460px at 15% 0%, rgba(61, 168, 194, 0.24), transparent 62%),
      radial-gradient(700px 380px at 90% 100%, rgba(11, 79, 108, 0.12), transparent 60%),
      #e8eef1;
  }

  /* ---------------------------------------------------------------------
     Sidebar
     --------------------------------------------------------------------- */
  .app-sidebar {
    position: relative;
    z-index: 40;
    display: flex;
    min-height: 0;
    flex-direction: column;
    overflow-y: auto;
    padding: 1.35rem 1rem 1rem;
    border-right: 1px solid rgba(11, 79, 108, 0.08);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 10px 0 34px rgba(8, 52, 69, 0.035);
  }

  .app-sidebar__brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.15rem 0.5rem;
    color: inherit;
    text-decoration: none;
  }

  .app-sidebar__brand-logo {
    display: grid;
    place-items: center;
    width: 2.65rem;
    height: 2.65rem;
    flex: 0 0 auto;
    padding: 0.2rem;
    border: 1px solid #dceef2;
    border-radius: 0.9rem;
    background: linear-gradient(145deg, #fff, #edf8fa);
    box-shadow: 0 5px 14px rgba(11, 79, 108, 0.08);
  }

  .app-sidebar__brand-logo img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .app-sidebar__brand-text {
    display: grid;
    gap: 0.08rem;
    min-width: 0;
  }

  .app-sidebar__brand-text strong {
    font-family: Sora, sans-serif;
    font-size: 0.86rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1.2;
    color: #083445;
  }

  .app-sidebar__brand-text small {
    overflow: hidden;
    color: #6b8490;
    font-size: 0.63rem;
    font-weight: 600;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar__section {
    margin: 1.45rem 0.7rem 0.5rem;
    color: #8aa2ac;
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
  }

  .app-sidebar__nav {
    display: grid;
    gap: 0.16rem;
  }

  .app-sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    min-height: 2.55rem;
    padding: 0.45rem 0.65rem;
    border: 1px solid transparent;
    border-radius: 0.8rem;
    color: #55717d;
    font-size: 0.81rem;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    transition:
      background 0.18s ease,
      color 0.18s ease,
      border-color 0.18s ease;
  }

  .app-sidebar__item:hover {
    border-color: rgba(33, 137, 166, 0.1);
    background: #f2f9fb;
    color: #0b4f6c;
  }

  .app-sidebar__item.is-active {
    border-color: rgba(33, 137, 166, 0.16);
    background: linear-gradient(135deg, #e8f7fa, #d8eff4);
    color: #0b4f6c;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  }

  .app-sidebar__icon {
    display: grid;
    place-items: center;
    width: 1.85rem;
    height: 1.85rem;
    flex: 0 0 auto;
    border-radius: 0.55rem;
    color: #1d6f8a;
    background: #f1f8fa;
  }

  .app-sidebar__item.is-active .app-sidebar__icon {
    color: #fff;
    background: linear-gradient(145deg, #2189a6, #0b4f6c);
    box-shadow: 0 4px 10px rgba(11, 79, 108, 0.18);
  }

  .app-sidebar__icon svg {
    width: 1.05rem;
    height: 1.05rem;
  }

  .app-sidebar__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    margin-left: auto;
    padding: 0 0.3rem;
    border-radius: 999px;
    color: #fff;
    background: #e07a5f;
    font-size: 0.6rem;
    font-weight: 800;
    line-height: 1;
  }

  .app-sidebar__footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid #edf3f5;
  }

  .app-sidebar__user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    padding: 0.5rem;
    border-radius: 0.85rem;
    color: inherit;
    text-decoration: none;
    transition: background 0.18s ease;
  }

  .app-sidebar__user:hover {
    background: #f3f9fb;
  }

  .app-sidebar__avatar {
    display: grid;
    place-items: center;
    width: 2.3rem;
    height: 2.3rem;
    flex: 0 0 auto;
    border-radius: 999px;
    color: #0b4f6c;
    background: linear-gradient(145deg, #d8f2f5, #b8e1e9);
    box-shadow: 0 0 0 1px #d4e8ed;
    font-family: Sora, sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
  }

  .app-sidebar__user-text {
    display: grid;
    gap: 0.1rem;
    min-width: 0;
  }

  .app-sidebar__user-text strong {
    overflow: hidden;
    color: #083445;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar__user-text small {
    overflow: hidden;
    color: #7b929c;
    font-size: 0.62rem;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .app-sidebar__logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    width: 100%;
    margin-top: 0.55rem;
    padding: 0.6rem 0.7rem;
    border-radius: 0.7rem;
    color: #a33a2c;
    background: #fff3f1;
    font-size: 0.74rem;
    font-weight: 800;
  }

  .app-sidebar__logout:hover {
    background: #ffe8e3;
  }

  .app-sidebar__logout svg {
    width: 1rem;
    height: 1rem;
  }

  /* ---------------------------------------------------------------------
     Header atas
     --------------------------------------------------------------------- */
  .app-topbar {
    padding-top: 0;
    border-bottom: 1px solid rgba(11, 79, 108, 0.08);
    background: rgba(255, 255, 255, 0.9);
    color: #083445;
    box-shadow: 0 6px 22px rgba(8, 52, 69, 0.035);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .app-topbar__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.9rem clamp(1.5rem, 2.4vw, 2.5rem);
    gap: 0.85rem;
  }

  .app-topbar__logo {
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid #e0eef2;
    border-radius: 0.85rem;
    box-shadow: 0 4px 12px rgba(11, 79, 108, 0.06);
  }

  .app-topbar__brand {
    color: #5f7d89;
    font-size: 0.6rem;
  }

  .app-topbar__title {
    margin-top: 0.12rem;
    color: #083445;
    font-size: 1.4rem;
    letter-spacing: -0.03em;
  }

  .app-topbar__sub {
    color: #6d8792;
    font-size: 0.78rem;
  }

  .dashboard-header {
    padding-top: 0;
    border-bottom: 1px solid rgba(11, 79, 108, 0.08);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 22px rgba(8, 52, 69, 0.035);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .dashboard-header__inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0.85rem clamp(1.5rem, 2.4vw, 2.5rem);
  }

  /* ---------------------------------------------------------------------
     Beranda pegawai
     --------------------------------------------------------------------- */
  .dashboard-home {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.15rem;
    max-width: 1180px !important;
    padding-top: 0 !important;
    padding-bottom: 1rem !important;
  }

  .dashboard-hero {
    min-height: 17.5rem;
    padding: 1.65rem 1.7rem 3.25rem;
  }

  .dashboard-hero__content {
    margin-top: 1.7rem;
  }

  .dashboard-hero__content h1 {
    font-size: 2.25rem;
    line-height: 1.18;
  }

  .dashboard-hero__content > p {
    margin-top: 0.6rem;
    font-size: 0.92rem;
  }

  .dashboard-hero__eyebrow {
    font-size: 0.66rem;
  }

  .dashboard-hero__date {
    font-size: 0.65rem;
  }

  .dashboard-hero__role {
    margin-top: 1rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.72rem;
  }

  .dashboard-attendance {
    margin: 0;
    padding: 1rem 1.1rem;
  }

  .dashboard-action {
    margin: 0;
    padding: 1rem 1.1rem;
  }

  .dashboard-services__head {
    margin-bottom: 1rem;
  }

  .dashboard-kicker {
    font-size: 0.64rem;
  }

  .dashboard-services__head h2 {
    font-size: 1.35rem;
  }

  .dashboard-services__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
  }

  .dashboard-service {
    min-height: 9.5rem;
    padding: 1.1rem;
  }

  .dashboard-service__label {
    font-size: 0.95rem;
  }

  .dashboard-service__description {
    font-size: 0.72rem;
  }

  .dashboard-home__footer {
    margin-top: 0.2rem;
    font-size: 0.7rem;
  }

  /* ---------------------------------------------------------------------
     Absensi: pilih slot
     --------------------------------------------------------------------- */
  .attendance-home {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1.15rem;
    max-width: 1180px !important;
    padding-top: 0 !important;
  }

  .attendance-home > .home-hero,
  .attendance-home > .shift-guide {
    grid-column: 1 / -1;
  }

  .attendance-home .home-hero {
    padding: 1.65rem 1.7rem 1.4rem;
  }

  .home-hero__message {
    font-size: 1.55rem;
  }

  .home-slots__grid {
    gap: 0.9rem;
  }

  .app-phone > main.absen-flow {
    max-width: 940px !important;
  }

  /* ---------------------------------------------------------------------
     Halaman lain
     --------------------------------------------------------------------- */
  .app-phone > main.cuti-page {
    max-width: 980px !important;
  }

  .cuti-page #leaveHistoryList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  .cuti-page #leaveHistoryList > * {
    margin-top: 0 !important;
  }

  .app-phone > main.spk-page {
    max-width: 1000px !important;
  }

  .app-phone > main.lacak-page {
    max-width: 1120px !important;
  }

  .lacak-page .lacak-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  .app-phone > main.riwayat-page {
    max-width: 1120px !important;
  }

  .riwayat-page #historyList {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .riwayat-page #historyList > * {
    margin-top: 0 !important;
  }

  .app-phone > main.profil-page {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: start;
    max-width: 980px !important;
  }

  .profil-page > * {
    margin-top: 0 !important;
  }

  .profil-page > section {
    grid-column: 1 / -1;
  }

  .profil-page > form[action="/api/logout.php"] {
    grid-column: 1 / -1;
  }

  .app-phone > main.bawahan-page {
    max-width: 1280px !important;
  }

  .bawahan-page .team-block .space-y-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .bawahan-page .team-block .space-y-2 > * {
    margin-top: 0 !important;
  }

  .app-phone > main.kinerja-page,
  .app-phone > main.produksi-page {
    max-width: 1220px !important;
  }

  /* ---------------------------------------------------------------------
     Login
     --------------------------------------------------------------------- */
  .login-screen {
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem;
  }

  .login-screen__body {
    max-width: 34rem;
    margin-block: auto;
    padding: 2.5rem 1.5rem 3rem;
  }

  /* Scrollbar halus */
  .app-phone > main,
  .app-sidebar {
    scrollbar-color: rgba(11, 79, 108, 0.22) transparent;
    scrollbar-width: thin;
  }

  .app-phone > main::-webkit-scrollbar,
  .app-sidebar::-webkit-scrollbar {
    width: 9px;
  }

  .app-phone > main::-webkit-scrollbar-thumb,
  .app-sidebar::-webkit-scrollbar-thumb {
    border: 2px solid transparent;
    border-radius: 999px;
    background: rgba(11, 79, 108, 0.22);
    background-clip: content-box;
  }
}

@media (min-width: 1280px) {
  .dashboard-home {
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 1fr);
    align-items: start;
  }

  .dashboard-home > .dashboard-hero {
    grid-row: span 2;
  }

  .dashboard-home > .dashboard-services,
  .dashboard-home > .dashboard-home__footer {
    grid-column: 1 / -1;
  }

  .dashboard-services__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .attendance-home {
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    align-items: start;
  }

  .attendance-home > .home-hero {
    grid-column: 1 / -1;
  }

  .attendance-home > .home-slots {
    grid-column: 1;
  }

  .attendance-home > .home-tips {
    grid-column: 2;
  }
}

@media print {
  .app-sidebar {
    display: none !important;
  }

  .app-phone {
    display: block !important;
    height: auto !important;
    overflow: visible !important;
  }

  .app-phone > main {
    max-width: none !important;
    padding: 0 !important;
    overflow: visible !important;
  }
}
