/* Responsive layer for the existing compiled Vue application. */

/* The mobile navigation exists in the DOM on authenticated pages, but is visible only at the phone breakpoint. */
.tac-mobile-nav { display: none; }

/* Small desktop/tablet: the original 700px form + 400px side panel cannot fit beside the sidebar. */
@media (max-width: 1366px) {
  .tac-page-apply .el-card__body > div[style*="display: flex"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    min-width: 0 !important;
  }
  .tac-page-apply form.el-form {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  .tac-page-apply form.el-form + div[style*="width: 400px"] {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  .tac-page-apply .el-form-item__content { min-width: 0; }
  .tac-page-apply .el-tabs { min-width: 0; max-width: 100%; }
}

@media (max-width: 768px) {
  html, body, #app { width: 100%; min-width: 0; overflow-x: hidden; }
  .el-container { min-width: 0; }
  .el-container > .aside { width: 0 !important; min-width: 0 !important; overflow: hidden !important; }

  .header { height: 52px !important; padding: 0 12px !important; }
  .header-left { gap: 8px !important; min-width: 0; }
  .header-left > button:first-child { display: none !important; }
  .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-info span { display: none; }
  .main { padding: 10px !important; padding-bottom: calc(82px + env(safe-area-inset-bottom)) !important; }

  .el-card__header { padding: 13px 14px !important; }
  .el-card__body { padding: 12px !important; }
  .el-dialog {
    width: calc(100vw - 16px) !important;
    max-width: none !important;
    margin: 8px auto !important;
    max-height: calc(100dvh - 16px);
    display: flex;
    flex-direction: column;
  }
  .el-dialog__header { padding: 14px 44px 12px 14px !important; flex: 0 0 auto; }
  .el-dialog__body { padding: 8px 12px 18px !important; overflow-y: auto; min-height: 0; }
  .el-dialog__footer { padding: 10px 12px !important; }
  .el-dialog__body > div[style*="display: flex"] { display: block !important; }
  .el-dialog__body div[style*="width: 380px"] { width: 100% !important; margin-top: 18px; }

  .el-descriptions__cell { word-break: break-word; }
  .el-form-item { display: block !important; }
  .el-form-item__label { width: auto !important; justify-content: flex-start !important; margin-bottom: 4px; }
  .el-form-item__content { margin-left: 0 !important; }
  .el-input, .el-select, .el-date-editor { max-width: 100% !important; width: 100% !important; }
  .el-table { width: 100% !important; font-size: 13px; }
  .el-table__body-wrapper, .el-table__header-wrapper { overflow-x: auto !important; }
  .el-button { min-height: 40px; }
  .el-dialog .el-form-item:last-child .el-button { min-width: 112px; margin: 4px 8px 4px 0; }

  .tac-settings-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .tac-settings-placeholder { display: none !important; }
  .login-container, .register-container { padding: 16px !important; }
  .login-card, .register-card { width: 100% !important; max-width: 420px !important; box-sizing: border-box; }
  .login-corner-logo { display: none !important; }

  /* Dashboard: 2x2 statistics and full-width action sections prevent narrow text columns. */
  .tac-page-dashboard main .el-col-6 { flex: 0 0 50% !important; max-width: 50% !important; }
  .tac-page-dashboard main .el-col-12 { flex: 0 0 100% !important; max-width: 100% !important; margin-bottom: 10px; }
  .tac-page-dashboard .stat-value { font-size: 28px !important; }
  .tac-page-dashboard .stat-label { font-size: 13px !important; white-space: nowrap; }
  .tac-page-dashboard .quick-actions .el-button { font-size: 13px; white-space: normal; line-height: 1.35; }
  .tac-page-dashboard .pending-item { align-items: flex-start !important; gap: 8px; font-size: 13px; }

  .tac-mobile-nav {
    position: fixed;
    z-index: 1900;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(58px + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: rgba(255,255,255,.98);
    border-top: 1px solid #dcdfe6;
    box-shadow: 0 -3px 12px rgba(0,0,0,.06);
  }
  .tac-mobile-nav a {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #70757d;
    text-decoration: none;
    font-size: 11px;
  }
  .tac-mobile-nav a.is-active { color: var(--el-color-primary, #409eff); font-weight: 600; }
  .tac-mobile-nav-icon { height: 22px; font-size: 21px; line-height: 22px; }

  /* Application form: a vertical, thumb-friendly flow instead of a squeezed desktop form. */
  .tac-page-apply .el-card__body > div[style*="display: flex"] { display: block !important; }
  .tac-page-apply form.el-form {
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  .tac-page-apply form.el-form > .el-form-item {
    margin-bottom: 12px;
    padding: 12px;
    background: #fff;
    border: 1px solid #ebeef5;
    border-radius: 8px;
  }
  .tac-page-apply .el-radio-group { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
  .tac-page-apply .el-radio { margin: 0 !important; min-height: 40px; padding: 0 8px; justify-content: center; border: 1px solid #dcdfe6; border-radius: 6px; }
  .tac-page-apply .el-radio.is-checked { border-color: var(--el-color-primary, #409eff); background: #ecf5ff; }
  .tac-page-apply .el-form-item__content div[style*="display: flex"] { flex-wrap: wrap; }
  .tac-page-apply .el-form-item__content div[style*="width: 320px"] { width: 100% !important; }
  .tac-page-apply .el-tabs__nav-wrap { overflow-x: auto; }
  .tac-page-apply .el-tabs__nav-scroll { width: max-content; min-width: 100%; }
  .tac-page-apply .el-tabs__item { padding: 0 14px !important; }
  .tac-page-apply .el-row { display: block !important; margin: 0 !important; }
  .tac-page-apply .el-col { width: 100% !important; max-width: none !important; padding: 0 !important; }
  .tac-page-apply .el-tree { max-height: 190px; overflow-y: auto; margin-bottom: 10px; border: 1px solid #ebeef5; border-radius: 6px; padding: 5px; }
  .tac-page-apply form + div[style*="width: 400px"] { width: 100% !important; min-width: 0 !important; max-width: none !important; margin-top: 12px; }
  .tac-page-apply form + div[style*="width: 400px"] { display: none !important; }

  .tac-page-apply .tac-mobile-permission-panel {
    display: block !important;
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    margin-top: 12px;
  }
  .tac-page-apply .tac-people-permissions > .el-form-item__content {
    display: block !important;
    width: 100% !important;
  }
  .tac-page-apply .tac-mobile-permission-toggle {
    width: 100%;
    min-height: 42px;
    margin: 6px 0;
    padding: 0 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--el-color-primary, #409eff);
    background: #fff;
    border: 1px solid var(--el-color-primary-light-5, #a0cfff);
    border-radius: 6px;
    font: inherit;
  }
  .tac-page-apply .tac-mobile-permission-toggle.is-unavailable {
    color: #909399;
    border-color: #dcdfe6;
    background: #f5f7fa;
  }
  .tac-page-apply .tac-toggle-arrow { font-size: 12px; }
  .tac-page-apply .tac-mobile-permission-card { display: none !important; margin: 6px 0 10px !important; }
  .tac-page-apply .tac-mobile-permission-card.is-expanded { display: block !important; }
  .tac-page-apply .tac-mobile-permission-card .el-card__header { display: none; }
  .tac-page-apply .tac-mobile-permission-card .el-card__body { padding: 12px !important; }
  .tac-page-apply .el-form-item__content div[style*="min-width: 200px"] {
    box-sizing: border-box;
    width: 100% !important;
    min-width: 0 !important;
    margin-top: 8px;
    padding: 10px !important;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    background: #f8f9fa;
  }
  .tac-page-apply form.el-form > .el-form-item:last-child {
    position: static;
    z-index: auto;
    margin: 0 0 12px;
    padding: 10px;
    background: #fff;
    box-shadow: none;
  }
  .tac-page-apply form.el-form > .el-form-item:last-child .el-button { width: 100%; min-height: 46px; }

  /* Operational lists become readable cards; desktop keeps the original tables. */
  .tac-page-pending-approvals .el-table__header-wrapper,
  .tac-page-my-applications .el-table__header-wrapper,
  .tac-page-doors .el-table__header-wrapper,
  .tac-page-permission-query .el-table__header-wrapper,
  .el-dialog .el-table__header-wrapper { display: none !important; }
  .tac-page-pending-approvals .el-table__body,
  .tac-page-my-applications .el-table__body,
  .tac-page-doors .el-table__body,
  .tac-page-permission-query .el-table__body,
  .el-dialog .el-table__body { display: block !important; width: 100% !important; }
  .tac-page-pending-approvals .el-table__body tbody,
  .tac-page-my-applications .el-table__body tbody,
  .tac-page-doors .el-table__body tbody,
  .tac-page-permission-query .el-table__body tbody,
  .el-dialog .el-table__body tbody { display: block !important; width: 100% !important; }
  .tac-page-pending-approvals .el-table__body tr,
  .tac-page-my-applications .el-table__body tr,
  .tac-page-doors .el-table__body tr,
  .tac-page-permission-query .el-table__body tr,
  .el-dialog .el-table__body tr {
    display: block !important;
    width: 100% !important;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid #e4e7ed;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
  }
  .tac-page-pending-approvals .el-table__body td,
  .tac-page-my-applications .el-table__body td,
  .tac-page-doors .el-table__body td,
  .tac-page-permission-query .el-table__body td,
  .el-dialog .el-table__body td {
    position: static !important;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    width: 100% !important;
    box-sizing: border-box;
    padding: 6px 0 !important;
    border: 0 !important;
    background: transparent !important;
    white-space: normal;
  }
  .tac-page-pending-approvals .el-table__body td::before,
  .tac-page-my-applications .el-table__body td::before,
  .tac-page-doors .el-table__body td::before,
  .tac-page-permission-query .el-table__body td::before,
  .el-dialog .el-table__body td::before { content: attr(data-label); color: #909399; font-size: 12px; }
  .tac-page-pending-approvals .el-table__body td .cell,
  .tac-page-my-applications .el-table__body td .cell,
  .tac-page-doors .el-table__body td .cell,
  .tac-page-permission-query .el-table__body td .cell,
  .el-dialog .el-table__body td .cell { padding: 0 !important; white-space: normal !important; overflow: visible !important; }

  .tac-page-pending-approvals td[data-label="审批进展"],
  .tac-page-my-applications td[data-label="审批进展"],
  .tac-page-pending-approvals td[data-label="最近操作"],
  .tac-page-my-applications td[data-label="最近操作"] { display: none !important; }
  .tac-page-pending-approvals td[data-label="操作"] .el-button,
  .tac-page-my-applications td[data-label="操作"] .el-button { width: 100%; }

  /* Door search: filters use the full width and results are cards, so no detached scrollbar. */
  .tac-page-doors .el-card__header > div { flex-wrap: wrap; gap: 8px; align-items: stretch !important; }
  .tac-page-doors .el-card__header > div > div { display: flex; width: 100%; flex-wrap: wrap; gap: 8px; }
  .tac-page-doors .el-card__header .el-input { flex: 1 1 100%; margin-right: 0 !important; }
  .tac-page-doors .el-card__header .el-button { flex: 1 1 auto; margin: 0 !important; }
  .tac-page-doors .el-card__body > .el-row { display: block !important; margin: 0 !important; }
  .tac-page-doors .el-card__body > .el-row > .el-col { width: 100% !important; max-width: none !important; padding: 0 !important; }
  .tac-page-doors .el-tree {
    display: flex;
    gap: 6px;
    max-width: 100%;
    margin: 0 0 10px;
    padding: 4px 0 8px;
    overflow-x: auto;
    border-bottom: 1px solid #ebeef5;
  }
  .tac-page-doors .el-tree > .el-tree-node { flex: 0 0 auto; min-width: 92px; }
  .tac-page-doors .el-tree-node__content { min-height: 38px; border: 1px solid #dcdfe6; border-radius: 6px; padding-right: 8px; }
  .tac-page-doors .el-pagination .el-pager li:nth-child(n+5):not(:last-child) { display: none; }

  /* Description tables become label/value rows instead of four squeezed desktop columns. */
  .el-dialog .el-descriptions__table,
  .el-dialog .el-descriptions__table tbody { display: block !important; width: 100% !important; }
  .el-dialog .el-descriptions__table tr {
    display: grid !important;
    grid-template-columns: 88px minmax(0, 1fr);
    width: 100% !important;
  }
  .el-dialog .el-descriptions__table td,
  .el-dialog .el-descriptions__table th { display: block !important; width: auto !important; box-sizing: border-box; }
}

@media (min-width: 769px) {
  .tac-mobile-permission-toggle { display: none !important; }
}

@media (max-width: 480px) {
  .el-message-box { width: calc(100vw - 24px) !important; }
  .el-pagination { justify-content: center; flex-wrap: wrap; row-gap: 8px; }
}
