/* ========================================
   ZIP to PDF — Mobile Design System
   ======================================== */

/* ---- Mobile View Mode: Root Variables ---- */
body.mobile-view {
  --mobile-bg: #0b0c10;
  --mobile-surface: #14151b;
  --mobile-nav-bg: #0f1015;
  --mobile-nav-text: #8a90a0;
  --mobile-nav-active: #f2f4f8;
  --mobile-accent: #7c8cff;
  --mobile-accent-soft: rgba(124, 140, 255, 0.14);
  --mobile-coral: #ff8183;
  --mobile-text: #f2f4f8;
  --mobile-text-secondary: #a8aebd;
  --mobile-text-muted: #7e8494;
  --mobile-border: rgba(255, 255, 255, 0.1);
  --mobile-radius: 12px;
  --mobile-radius-sm: 8px;
  --mobile-shadow: 0 2px 16px rgba(0, 0, 0, 0.55);
  --mobile-bottom-nav-height: 64px;
  --mobile-top-bar-height: 56px;
  --mobile-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Microsoft YaHei', 'PingFang SC', sans-serif;
  
  background: var(--mobile-bg);
  font-family: var(--mobile-font);
}

/* ---- Hide desktop elements in mobile mode ---- */
body.mobile-view .top-header,
body.mobile-view .main-navigation,
body.mobile-view .sidebar {
  display: none !important;
}

/* 顶栏图标按钮已自带尺寸，抵消全局 .icon 的放大 */
body.mobile-view .mobile-top-bar .icon {
  font-size: 1em;
}

/* ---- Mobile Shell ---- */
body.mobile-view .mobile-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: var(--mobile-bottom-nav-height);
}

body.mobile-view .mobile-content {
  flex: 1;
  padding: 12px 16px;
  padding-top: calc(var(--mobile-top-bar-height) + 12px);
  max-width: 100%;
  overflow-x: hidden;
}

/* ---- Mobile Top Bar ---- */
.mobile-top-bar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-top-bar-height);
  background: var(--mobile-surface);
  border-bottom: 1px solid var(--mobile-border);
  z-index: 200;
  padding: 0 12px;
  align-items: center;
  justify-content: space-between;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.mobile-view .mobile-top-bar {
  display: flex;
}

.mobile-top-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-hamburger {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  color: var(--mobile-text);
  font-size: 20px;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-hamburger:active {
  background: var(--mobile-accent-soft);
}

.mobile-top-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--mobile-text);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.mobile-top-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ---- View Mode Toggle Button ---- */
.view-toggle-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  border-radius: 50%;
  font-size: 18px;
  color: var(--mobile-text-secondary);
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.view-toggle-btn:active {
  background: var(--mobile-accent-soft);
  color: var(--mobile-accent);
}

.view-toggle-btn .tooltip {
  display: none;
  position: absolute;
  bottom: -28px;
  right: 0;
  background: var(--mobile-nav-bg);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-weight: 500;
  z-index: 300;
}

.view-toggle-btn:hover .tooltip {
  display: block;
}

/* ---- Mobile Bottom Tab Bar ---- */
.mobile-bottom-nav {
  display: none !important;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-bottom-nav-height);
  background: var(--mobile-nav-bg);
  z-index: 200;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.15);
}

body.mobile-view .mobile-bottom-nav {
  display: flex !important;
}

.mobile-bottom-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.mobile-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 12px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--mobile-nav-text);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  transition: color 0.2s;
  min-width: 56px;
}

.mobile-tab-item .tab-icon {
  font-size: 22px;
  line-height: 1;
  transition: transform 0.2s;
}

.mobile-tab-item .tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.mobile-tab-item.active {
  color: var(--mobile-nav-active);
}

.mobile-tab-item.active .tab-icon {
  transform: scale(1.05);
}

/* Active indicator pill */
.mobile-tab-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 3px;
  background: var(--mobile-accent);
  border-radius: 0 0 3px 3px;
}

.mobile-tab-item:active {
  opacity: 0.7;
}

/* ---- Mobile Sidebar Drawer ---- */
.mobile-drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-drawer-overlay.open {
  display: block;
  opacity: 1;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  max-width: 85vw;
  background: var(--mobile-surface);
  z-index: 301;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

.mobile-drawer.open {
  transform: translateX(0);
}

.mobile-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--mobile-border);
}

.mobile-drawer-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mobile-drawer-logo img {
  height: 36px;
  width: auto;
  border-radius: 6px;
}

.mobile-drawer-logo span {
  font-size: 16px;
  font-weight: 700;
  color: var(--mobile-text);
}

.mobile-drawer-close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--mobile-accent-soft);
  cursor: pointer;
  border-radius: 50%;
  font-size: 16px;
  color: var(--mobile-text-secondary);
  -webkit-tap-highlight-color: transparent;
}

.mobile-drawer-user {
  padding: 16px;
  border-bottom: 1px solid var(--mobile-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mobile-drawer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--mobile-accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--mobile-accent);
}

.mobile-drawer-username {
  font-size: 15px;
  font-weight: 600;
  color: var(--mobile-text);
}

.mobile-drawer-role {
  font-size: 12px;
  color: var(--mobile-text-muted);
}

.mobile-drawer-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--mobile-border);
}

.mobile-drawer-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--mobile-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 0 16px 8px;
}

.mobile-drawer-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--mobile-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-drawer-link:active {
  background: var(--mobile-accent-soft);
}

.mobile-drawer-link .link-icon {
  width: 24px;
  text-align: center;
  font-size: 16px;
  color: var(--mobile-text-secondary);
}

.mobile-drawer-view-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.mobile-drawer-view-toggle span {
  font-size: 14px;
  font-weight: 500;
  color: var(--mobile-text);
}

/* ---- Toggle Switch Component ---- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--mobile-border);
  border-radius: 14px;
  transition: background 0.3s;
}

.toggle-slider::before {
  content: '📱';
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  left: 3px;
  bottom: 3px;
  width: 22px;
  height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--mobile-accent);
}

.toggle-switch input:checked + .toggle-slider::before {
  content: '💻';
  transform: translateX(20px);
}

/* ---- Mobile Content Overrides ---- */
body.mobile-view .layout-container {
  display: block !important;
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.mobile-view .content-wrapper {
  margin: 0 !important;
  max-width: 100% !important;
}

body.mobile-view .container {
  max-width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
}

body.mobile-view .content {
  border-radius: var(--mobile-radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--mobile-border);
  box-shadow: var(--mobile-shadow);
}

body.mobile-view .page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  border-radius: var(--mobile-radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  background: var(--mobile-surface);
  border: 1px solid var(--mobile-border);
  box-shadow: var(--mobile-shadow);
}

body.mobile-view .page-header h1 {
  font-size: 1.3em;
}

body.mobile-view .page-header-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
}

body.mobile-view .page-header-svg {
  width: 22px;
  height: 22px;
}

body.mobile-view .upload-area,
body.mobile-view .upload-zone {
  padding: 32px 20px;
  border-radius: var(--mobile-radius);
}

body.mobile-view .upload-icon {
  width: 58px;
  height: 58px;
  border-radius: 18px;
  font-size: 2.4em;
}

body.mobile-view .upload-icon-svg {
  width: 28px;
  height: 28px;
}

body.mobile-view .supported-formats {
  border-radius: var(--mobile-radius);
}

body.mobile-view .formats-grid {
  grid-template-columns: repeat(2, 1fr);
}

body.mobile-view .file-item,
body.mobile-view .pdf-item {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  border-radius: var(--mobile-radius-sm);
}

body.mobile-view .blog-content {
  border-radius: var(--mobile-radius);
  padding: 16px;
  border: 1px solid var(--mobile-border);
  box-shadow: var(--mobile-shadow);
  margin-bottom: 12px;
}

body.mobile-view .post-title {
  font-size: 1.3em;
}

body.mobile-view .post-body {
  font-size: 0.92em;
}

body.mobile-view .post-body pre {
  font-size: 0.82em;
  overflow-x: auto;
  border-radius: var(--mobile-radius-sm);
}

body.mobile-view .footer {
  padding: 16px;
  font-size: 0.82em;
  text-align: center;
  color: var(--mobile-text-muted);
  border-top: 1px solid var(--mobile-border);
  margin-top: 20px;
}

/* ---- Mobile Admin Overrides ---- */
body.mobile-view .admin-wrapper {
  padding: 0;
}

body.mobile-view .admin-box {
  border-radius: var(--mobile-radius);
  padding: 16px;
  border: 1px solid var(--mobile-border);
  box-shadow: var(--mobile-shadow);
}

body.mobile-view .admin-nav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
}

body.mobile-view .admin-nav a {
  padding: 8px 14px;
  font-size: 0.85em;
}

body.mobile-view .stats-grid {
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

body.mobile-view .stat-card {
  padding: 14px;
  border-radius: var(--mobile-radius-sm);
}

body.mobile-view .stat-card .number {
  font-size: 1.4em;
}

/* ---- Mobile Modal ---- */
body.mobile-view .modal-box {
  border-radius: var(--mobile-radius);
  padding: 20px 24px;
  width: 92%;
  max-width: 380px;
}

/* ---- Mobile Tables ---- */
body.mobile-view .posts-table th,
body.mobile-view .posts-table td {
  padding: 8px 10px;
  font-size: 0.85em;
}

/* ---- Mobile Form Elements ---- */
body.mobile-view .form-control {
  font-size: 16px; /* prevent iOS zoom on focus */
  border-radius: var(--mobile-radius-sm);
}

body.mobile-view .upload-btn,
body.mobile-view .download-btn,
body.mobile-view .tool-btn,
body.mobile-view .btn {
  padding: 10px 20px;
  font-size: 15px;
  border-radius: var(--mobile-radius-sm);
  min-height: 44px; /* touch target */
}

body.mobile-view input,
body.mobile-view select,
body.mobile-view textarea {
  font-size: 16px;
}

/* ---- Mobile Resources/Search Page ---- */
body.mobile-view .resource-card {
  border-radius: var(--mobile-radius-sm);
}

body.mobile-view .search-nav-form {
  width: 100%;
  max-width: 300px;
}

/* ---- Mobile Blog Editor ---- */
body.mobile-view .editor-wrapper {
  padding: 0;
}

body.mobile-view .CodeMirror {
  border-radius: var(--mobile-radius-sm);
}

/* ---- Mobile Pagination ---- */
body.mobile-view .pagination {
  gap: 4px;
}

body.mobile-view .pagination a,
body.mobile-view .pagination span {
  padding: 8px 12px;
  font-size: 0.85em;
  border-radius: 6px;
}

/* ---- Loading / Transition ---- */
body.mobile-view .mobile-content {
  animation: mobileFadeIn 0.25s ease;
}

@keyframes mobileFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- Safe area for notched devices ---- */
@supports (padding-top: env(safe-area-inset-top)) {
  body.mobile-view .mobile-top-bar {
    padding-top: env(safe-area-inset-top);
    height: calc(var(--mobile-top-bar-height) + env(safe-area-inset-top));
  }
  
  body.mobile-view .mobile-content {
    padding-top: calc(var(--mobile-top-bar-height) + 12px + env(safe-area-inset-top));
  }
  
  body.mobile-view .mobile-bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ---- Desktop View Mode Toggle ---- */
body:not(.mobile-view) .desktop-view-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84em;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  margin-left: 8px;
  -webkit-tap-highlight-color: transparent;
}

body:not(.mobile-view) .desktop-view-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

body:not(.mobile-view) .desktop-view-toggle .toggle-icon {
  width: 15px;
  height: 15px;
}

.desktop-view-toggle {
  display: none;
}

/* ---- Mobile view toggle in user menu area ---- */
.mobile-toggle-inline {
  display: none;
}

@media (max-width: 768px) {
  .desktop-view-toggle {
    display: flex !important;
  }
}

/* ---- V2：SVG 图标对齐 ---- */
.mobile-top-bar .icon-svg {
  width: 22px;
  height: 22px;
}

.mobile-tab-item .tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-tab-item .tab-icon .icon-svg {
  width: 22px;
  height: 22px;
}

.mobile-drawer-close .icon-svg {
  width: 18px;
  height: 18px;
}

.mobile-drawer-avatar .icon-svg {
  width: 22px;
  height: 22px;
}

.mobile-drawer-link .link-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mobile-drawer-link .link-icon .icon-svg {
  width: 17px;
  height: 17px;
}

.mobile-drawer-view-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mobile-drawer-view-label .icon-svg {
  width: 18px;
  height: 18px;
}

.mobile-drawer-logout .link-icon {
  color: currentColor;
}
