/* Mobile Responsive Styles */
@media (max-width: 768px) {
  /* General Mobile Styles */
  :root {
    --mobile-padding: 12px;
  }

  body {
    font-size: 16px;
    line-height: 1.35;
  }

  /* Topbar adjustments */
  .topbar {
    grid-template-columns: 1fr auto;
    padding: 8px 12px;
    height: auto;
    min-height: 56px;
  }

  .topbar__left {
    display: flex;
    align-items: center;
  }

  .topbar__center {
    display: none; /* Hide search on mobile */
  }

  .topbar__right {
    gap: 6px;
  }

  .account {
    display: none; /* Hide account name on mobile */
  }

  /* Main content adjustments */
  .main {
    padding: 12px;
    padding-bottom: 70px; /* Add padding for mobile menu */
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-actions {
    width: 100%;
    flex-wrap: wrap;
    gap: 8px;
  }

  .page-actions .btn {
    flex: 1 1 45%;
    min-width: 120px;
  }

  .page-title {
    font-size: 20px;
    line-height: 1.15;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding-bottom: 4px;
  }

  .tab {
    white-space: nowrap;
    font-size: 14px;
    padding: 10px 8px;
  }

  /* Table adjustments */
  .table-wrap {
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 0;
  }

  .col-inv,
  .col-cat,
  .col-ch {
    display: none;
  }

  .row-product {
    gap: 12px;
  }

  .pname {
    font-size: 15px;
  }

  /* Form elements */
  .field {
    margin-bottom: 16px;
  }

  .grid2 {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Editor layout */
  .editor-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    margin-top: 12px;
  }

  .editor-actions .btn {
    width: 100%;
    min-width: 0;
  }

  /* Make back button more touch-friendly */
  #backToListBtn {
    padding: 6px 10px;
    font-size: 13px;
    min-height: 36px;
    min-width: 100px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-right: 10px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  
  #backToListBtn:active,
  #backToListBtn.btn--pressed {
    background-color: #e0e0e0;
    transform: translateY(1px);
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
  }
  
  #backToListBtn i {
    font-size: 14px;
  }

  /* Make sure the back button is always visible when scrolling */
  .editor-top {
    position: sticky;
    top: 0;
    background: white;
    z-index: 20;
    padding: 12px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .editor-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    min-width: 0;
  }

  #editorCrumbTitle {
    flex: 1 1 100%;
    min-width: 0;
    font-size: 16px;
    line-height: 1.2;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  #editorBadge {
    flex: 0 0 auto;
  }

  .editor-actions {
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .editor-actions .btn {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
  }

  .editor-actions .menu {
    width: 100%;
  }

  .editor-actions .menu > .btn {
    width: 100%;
  }

  /* Modal adjustments */
  .modal__panel {
    width: 90%;
    max-width: 100%;
    margin: 20px;
  }

  .menu__panel {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 86px;
    top: auto;
    min-width: 0;
    max-height: calc(70vh - 86px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 16px;
    z-index: 1200;
  }

  .menu__item {
    padding: 10px 12px;
    font-size: 13px;
  }

  /* Make buttons more touch-friendly */
  .btn, button, [role="button"] {
    min-height: 36px;
    padding: 6px 10px;
    font-size: 13px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  /* Make form elements more touch-friendly */
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Hide less important elements on mobile */
  .kbd, .crumb__text {
    display: none;
  }

  /* Mobile menu */
  .mobile-menu {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #eee;
    padding: 10px 0;
    z-index: 1000;
  }

  .mobile-menu.active {
    display: block;
  }

  .mobile-menu-items {
    display: flex;
    justify-content: space-around;
  }

  .mobile-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 12px;
    color: #666;
    text-decoration: none;
    font-size: 12px;
    min-width: 64px;
  }

  .mobile-menu-item i {
    font-size: 20px;
    margin-bottom: 4px;
  }

  .mobile-menu-item.active {
    color: #111;
  }

  /* Adjust card padding */
  .card.pad {
    padding: 12px;
  }

  /* Save status indicator */
  .saving-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #666;
    margin-left: 12px;
  }

  /* Loading spinner */
  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  .fa-spin {
    animation: spin 1s linear infinite;
  }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
  .editor-grid {
    grid-template-columns: 1fr 300px;
  }
  
  .topbar {
    grid-template-columns: 200px 1fr auto;
    padding: 8px 16px;
  }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
  .editor-grid {
    grid-template-columns: 1fr 300px;
  }
  
  .topbar {
    grid-template-columns: 200px 1fr auto;
    padding: 8px 16px;
  }
}

/* Mobile menu styles */
.mobile-menu {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  padding: 8px 0;
  z-index: 1000;
}

.mobile-menu.active {
  display: block;
}

.mobile-menu-items {
  display: flex;
  justify-content: space-around;
  padding: 0 10px;
}

.mobile-menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  color: #6b7280;
  text-decoration: none;
  font-size: 12px;
}

.mobile-menu-item i {
  font-size: 20px;
  margin-bottom: 4px;
}

.mobile-menu-item.active {
  color: #111827;
}

/* Touch targets */
@media (max-width: 768px) {
  input[type="text"],
  input[type="number"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Make sure select elements are tappable */
  select {
    padding: 10px 16px;
  }
}

/* Prevent textarea zoom on iOS */
@media (max-width: 768px) {
  textarea {
    font-size: 16px !important;
  }
}
