/* Android-specific responsive shell. Loaded last to normalize phone, foldable,
   tablet portrait, landscape, keyboard, and system-bar behavior. */
html[data-platform="android"] {
  --android-header-height: 56px;
  --android-nav-height: 68px;
  height: 100%;
  overflow: hidden;
}

html[data-platform="android"] *,
html[data-platform="android"] *::before,
html[data-platform="android"] *::after {
  box-sizing: border-box;
}

html[data-platform="android"] body,
html[data-platform="android"] .app-container {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
}

html[data-platform="android"] img,
html[data-platform="android"] video,
html[data-platform="android"] canvas,
html[data-platform="android"] iframe {
  max-width: 100%;
  height: auto;
}

html[data-platform="android"] .table-responsive,
html[data-platform="android"] .employee-directory-table-wrap,
html[data-platform="android"] .employee-documents-table-wrap,
html[data-platform="android"] .task-board-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

html[data-platform="android"] .modal,
html[data-platform="android"] .modal-overlay {
  align-items: center !important;
  justify-content: center !important;
  padding: max(.65rem, env(safe-area-inset-top)) max(.65rem, env(safe-area-inset-right)) max(.65rem, env(safe-area-inset-bottom)) max(.65rem, env(safe-area-inset-left)) !important;
  overflow: hidden !important;
}

html[data-platform="android"] .modal-content,
html[data-platform="android"] .modal-content[style] {
  width: min(94vw, 920px) !important;
  max-width: min(94vw, 920px) !important;
  max-height: calc(100dvh - max(1.3rem, env(safe-area-inset-top) + env(safe-area-inset-bottom))) !important;
  margin: auto !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

html[data-platform="android"] .modal-header {
  position: sticky;
  top: -1px;
  z-index: 25;
  background: var(--color-bg-surface);
}

html[data-platform="android"] .modal-actions,
html[data-platform="android"] .form-actions {
  position: sticky;
  bottom: -1px;
  z-index: 20;
  padding-bottom: max(.75rem, env(safe-area-inset-bottom));
  background: var(--color-bg-surface);
}

html[data-platform="android"] .side-panel[hidden],
html[data-platform="android"] .side-panel-overlay[hidden] {
  display: none !important;
}

html[data-platform="android"] .side-panel:not(.active),
html[data-platform="android"] .side-panel-overlay:not(.active) {
  pointer-events: none;
  visibility: hidden;
}

html[data-platform="android"] input,
html[data-platform="android"] select,
html[data-platform="android"] textarea {
  max-width: 100%;
  font-size: 16px !important;
}

@media (max-width: 1024px) {
  html[data-platform="android"] .app-container {
    display: block;
  }

  html[data-platform="android"] .main-content {
    width: 100%;
    height: 100dvh;
    min-width: 0;
    overflow: hidden;
  }

  html[data-platform="android"] .topbar {
    width: 100%;
    height: calc(var(--android-header-height) + env(safe-area-inset-top));
    min-width: 0;
    padding: env(safe-area-inset-top) max(.75rem, env(safe-area-inset-right)) 0 max(.75rem, env(safe-area-inset-left)) !important;
    gap: .5rem !important;
  }

  html[data-platform="android"] .header-logo,
  html[data-platform="android"] .topbar-actions,
  html[data-platform="android"] .profile-dropdown-wrapper,
  html[data-platform="android"] .user-profile {
    min-width: 0;
  }

  html[data-platform="android"] .header-logo {
    flex: 1 1 auto;
    overflow: hidden;
  }

  html[data-platform="android"] .app-logo {
    width: auto;
    max-width: min(150px, 38vw) !important;
    max-height: 34px;
    object-fit: contain;
  }

  html[data-platform="android"] .topbar-actions {
    flex: 0 0 auto !important;
    gap: .4rem !important;
  }

  html[data-platform="android"] .user-info,
  html[data-platform="android"] .user-profile > svg,
  html[data-platform="android"] .user-profile > i {
    display: none !important;
  }

  html[data-platform="android"] .user-profile {
    padding: 0 !important;
    border: 0 !important;
  }

  html[data-platform="android"] .user-profile .avatar {
    width: 40px;
    height: 40px;
    min-width: 40px;
  }

  html[data-platform="android"] .view-container {
    width: 100%;
    height: calc(100dvh - var(--android-header-height) - env(safe-area-inset-top));
    min-width: 0;
    padding: 1rem max(1rem, env(safe-area-inset-right)) calc(var(--android-nav-height) + 1rem + env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  html[data-platform="android"] .sidebar {
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    display: block !important;
    width: 100%;
    height: calc(var(--android-nav-height) + env(safe-area-inset-bottom));
    padding: 0 max(.5rem, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(.5rem, env(safe-area-inset-left));
    overflow: visible;
    border: 0;
    border-top: 1px solid var(--sidebar-border);
    box-shadow: var(--shadow-lg);
  }

  html[data-platform="android"] body.login-screen .sidebar {
    display: none !important;
  }

  html[data-platform="android"] body.login-screen .view-container {
    height: 100dvh;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }

  html[data-platform="android"] .sidebar-header {
    display: none !important;
  }

  html[data-platform="android"] .sidebar-nav {
    display: grid !important;
    width: 100%;
    height: 100%;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    gap: .25rem;
    padding: .3rem 0;
    overflow: visible;
  }

  html[data-platform="android"] .sidebar-nav > .nav-item {
    display: none !important;
  }

  html[data-platform="android"] .sidebar-nav > .nav-item[data-view="dashboard"],
  html[data-platform="android"] .sidebar-nav > .nav-item[data-view="tasks"],
  html[data-platform="android"] .sidebar-nav > .nav-item[data-view="requests"],
  html[data-platform="android"] .sidebar-nav > .nav-item[data-view="time"],
  html[data-platform="android"] .sidebar-nav > #mobileMoreNav {
    display: flex !important;
  }

  html[data-platform="android"] .nav-item {
    width: 100%;
    min-width: 0;
    min-height: 56px;
    padding: .3rem .15rem;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .2rem;
    border-radius: 13px;
  }

  html[data-platform="android"] .nav-item > span {
    display: block;
    width: 100%;
    overflow: hidden;
    font-size: clamp(.56rem, 1.8vw, .72rem);
    line-height: 1.15;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  html[data-platform="android"] .nav-item > svg,
  html[data-platform="android"] .nav-item > i {
    width: 19px !important;
    height: 19px !important;
    padding: 0 !important;
    flex: 0 0 19px;
  }

  html[data-platform="android"] .mobile-navigation-sheet {
    padding-bottom: calc(var(--android-nav-height) + 1rem + env(safe-area-inset-bottom));
  }

  html[data-platform="android"] .mobile-navigation-panel {
    width: min(720px, 100%);
    max-height: calc(100dvh - var(--android-nav-height) - 2rem - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  html[data-platform="android"] .dashboard-grid,
  html[data-platform="android"] .dashboard-grid[style] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  html[data-platform="android"] .page-header {
    min-width: 0;
    flex-wrap: wrap;
    gap: .75rem;
  }

  html[data-platform="android"] .page-header > * {
    min-width: 0;
  }

  html[data-platform="android"] .task-v2-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html[data-platform="android"] .task-v2-search {
    grid-column: 1 / -1;
    min-width: 0;
  }

  html[data-platform="android"] .task-v2-workspace {
    grid-template-columns: minmax(0, 1fr);
  }

  html[data-platform="android"] .task-v2-lists {
    display: flex;
    max-width: 100%;
    gap: .4rem;
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--color-border);
    -webkit-overflow-scrolling: touch;
  }

  html[data-platform="android"] .task-v2-lists > * {
    flex: 0 0 auto;
  }

  html[data-platform="android"] .task-v2-lists h3 {
    display: none;
  }

  html[data-platform="android"] .task-v2-list-link {
    width: auto;
    min-width: max-content;
  }

  html[data-platform="android"] .side-panel,
  html[data-platform="android"] .side-panel.task-v2-detail,
  html[data-platform="android"] .side-panel.teamwork-task-detail,
  html[data-platform="android"] .side-panel.task-v2-detail.teamwork-task-detail {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    border: 0;
  }

  html[data-platform="android"] .side-panel-body {
    min-height: 0;
    overflow-y: auto;
  }

  html[data-platform="android"] #createTaskModal .modal-content {
    width: min(96vw, 920px) !important;
    max-width: min(96vw, 920px) !important;
    max-height: calc(100dvh - 1.3rem) !important;
  }

  html[data-platform="android"] #createTaskModal #standardTaskForm > div:first-of-type {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  html[data-platform="android"] .document-upload-modal-content,
  html[data-platform="android"] .employee-document-upload-content {
    width: min(96vw, 920px) !important;
  }
}

@media (max-width: 600px) {
  html[data-platform="android"] {
    --android-nav-height: 64px;
  }

  html[data-platform="android"] .view-container {
    padding-inline: max(.75rem, env(safe-area-inset-left));
  }

  html[data-platform="android"] .dashboard-grid,
  html[data-platform="android"] .dashboard-grid[style],
  html[data-platform="android"] .task-v2-toolbar,
  html[data-platform="android"] .task-v2-stats,
  html[data-platform="android"] #createTaskModal #standardTaskForm > div:first-of-type,
  html[data-platform="android"] .employee-document-upload-grid,
  html[data-platform="android"] .profile-contract-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html[data-platform="android"] .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  html[data-platform="android"] .page-header .btn,
  html[data-platform="android"] .page-header button {
    width: 100%;
  }

  html[data-platform="android"] .card {
    width: 100%;
    padding: .875rem;
    border-radius: 14px;
  }

  html[data-platform="android"] .modal-content,
  html[data-platform="android"] .modal-content[style] {
    width: 100% !important;
    max-width: 100% !important;
    max-height: calc(100dvh - .7rem - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    padding: .65rem !important;
    border-radius: 12px !important;
  }

  html[data-platform="android"] .modal-content > *,
  html[data-platform="android"] .modal-content form,
  html[data-platform="android"] .modal-content fieldset {
    min-width: 0;
    max-width: 100%;
  }

  html[data-platform="android"] .modal-content [style*="grid-template-columns"],
  html[data-platform="android"] .modal-content .modal-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  html[data-platform="android"] .modal-content form > div[style*="display: flex"],
  html[data-platform="android"] .modal-content .form-row,
  html[data-platform="android"] .task-assign-form > div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  html[data-platform="android"] .modal-actions,
  html[data-platform="android"] .form-actions,
  html[data-platform="android"] .employee-document-upload-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: .5rem;
  }

  html[data-platform="android"] .modal-actions .btn,
  html[data-platform="android"] .form-actions .btn,
  html[data-platform="android"] .employee-document-upload-actions .btn {
    width: 100%;
  }

  html[data-platform="android"] .task-v2-row {
    grid-template-columns: 28px 28px minmax(0, 1fr) 34px;
    gap: .4rem;
    padding-inline: .65rem;
  }

  html[data-platform="android"] .task-v2-status,
  html[data-platform="android"] .task-v2-priority,
  html[data-platform="android"] .task-v2-date {
    display: none;
  }

  html[data-platform="android"] .mobile-navigation-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  html[data-platform="android"] {
    --android-header-height: 50px;
    --android-nav-height: 58px;
  }

  html[data-platform="android"] .modal,
  html[data-platform="android"] .modal-overlay {
    padding-block: .35rem !important;
  }

  html[data-platform="android"] .modal-content,
  html[data-platform="android"] .modal-content[style] {
    max-height: calc(100dvh - .7rem) !important;
    border-radius: 12px !important;
  }

  html[data-platform="android"] .side-panel-header,
  html[data-platform="android"] .side-panel-footer {
    padding-block: .65rem;
  }
}
