/*
 * Mobile Overrides
 * Responsive styles using design tokens from application.css.
 * Primary breakpoint: 768px, small-screen breakpoint: 480px.
 */

/* ===== Hamburger Button ===== */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text);
}

/* ===== Nav Overlay ===== */
.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: 99;
}

.nav-overlay.active {
  display: block;
}

/* ===== Mobile Styles (max-width: 768px) ===== */
@media (max-width: 768px) {

  /* --- Hamburger Menu --- */
  .hamburger-btn {
    display: flex;
  }

  /* --- Nav Drawer --- */
  .nav-links {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: var(--color-bg-card);
    border-left: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-2xl) var(--space-xl);
    gap: 0;
    z-index: 200;
    overflow-y: auto;
    transition: right 0.3s ease;
  }

  .nav-links.nav-open {
    right: 0;
  }

  /* Flatten dropdown wrappers in mobile menu */
  .nav-dropdown {
    display: contents;
  }

  .nav-dropdown-menu {
    display: none;
  }

  .nav-links a,
  .nav-links form {
    display: flex;
    align-items: center;
    padding: var(--space-lg) 0;
    font-size: var(--font-size-md);
    border-bottom: 1px solid var(--color-border);
    min-height: var(--tap-target-min);
  }

  .nav-links a.btn,
  .nav-links .btn,
  .nav-links a.btn-secondary,
  .nav-links .btn-secondary {
    margin-top: var(--space-lg);
    text-align: center;
    justify-content: center;
    border-bottom: none;
  }


  /* --- Global Layout --- */
  .main-content {
    padding: var(--space-xl) var(--mobile-padding);
  }

  h1 {
    font-size: var(--font-size-xl);
  }

  h2 {
    font-size: var(--font-size-lg);
  }

  .page-header {
    margin-bottom: var(--space-xl);
  }

  .page-description {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  /* --- Touch Targets --- */
  .btn,
  a.btn,
  input[type="submit"].btn,
  button.btn {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-small {
    min-height: 36px;
    font-size: var(--font-size-sm);
  }

  .btn-icon {
    min-width: var(--tap-target-min);
    min-height: var(--tap-target-min);
  }

  .filter-btn {
    min-height: 0;
  }

  .wishlist-btn {
    width: 36px;
    height: 36px;
  }

  .wishlist-btn svg {
    width: 18px;
    height: 18px;
  }

  a.copy-link-btn {
    width: var(--tap-target-min);
    height: var(--tap-target-min);
  }

  .pagination .btn {
    min-height: var(--tap-target-min);
  }

  .pagination {
    gap: var(--space-md);
  }

  .searchable-select-option,
  .multi-select-option {
    min-height: var(--tap-target-min);
    display: flex;
    align-items: center;
  }

  /* --- Filter Bar (releases index) --- */
  .filter-bar {
    flex-direction: column;
    gap: var(--space-lg);
  }

  .filter-group-labeled {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .status-filter,
  .source-filter {
    flex-wrap: wrap;
    gap: var(--space-sm);
  }

  .releases-grid {
    grid-template-columns: 1fr;
  }

  /* --- Ratings Queue Filters --- */
  .filters-container {
    flex-direction: column;
    gap: var(--space-lg);
  }

  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .filter-tabs {
    flex-wrap: wrap;
  }

  /* --- Ratings Edit Page --- */
  .ratings-edit-layout {
    display: flex;
    flex-direction: column-reverse;
  }

  .ratings-edit-sidebar {
    position: static;
    margin-bottom: var(--space-xl);
  }

  .quick-search-links {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .quick-search-links .btn {
    flex: 1;
    min-width: calc(50% - var(--space-md));
  }

  .add-provider-buttons {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .add-provider-buttons .btn {
    flex: 1;
    min-width: calc(50% - var(--space-md));
  }

  .wine-meta-row {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .rating-form-actions {
    flex-direction: column;
    gap: var(--space-md);
  }

  .rating-form-actions-right {
    display: flex;
    gap: var(--space-md);
  }

  /* --- Admin Tables -> Cards --- */
  .producers-table,
  .providers-table,
  .users-table,
  .sync-history-table,
  .reviews-table {
    display: block;
    background: transparent;
    border: none;
  }

  .producers-table thead,
  .providers-table thead,
  .users-table thead,
  .sync-history-table thead,
  .reviews-table thead {
    display: none;
  }

  .producers-table tbody,
  .providers-table tbody,
  .users-table tbody,
  .sync-history-table tbody,
  .reviews-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }

  .producers-table tbody tr,
  .providers-table tbody tr,
  .users-table tbody tr,
  .sync-history-table tbody tr,
  .reviews-table tbody tr {
    display: block;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-lg);
  }

  .producers-table td,
  .providers-table td,
  .users-table td,
  .sync-history-table td,
  .reviews-table td {
    display: block;
    padding: var(--space-sm) 0;
    border: none;
    text-align: left;
  }

  /* First cell as card title */
  .producers-table td:first-child,
  .providers-table td:first-child,
  .users-table td:first-child {
    font-size: var(--font-size-md);
    font-weight: 600;
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-md);
  }

  /* Cell labels via ::before */
  .producers-table td:nth-child(2)::before { content: "Country: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .producers-table td:nth-child(3)::before { content: "Website: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .producers-table td:nth-child(4)::before { content: "Wines: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }

  .users-table td:nth-child(2)::before { content: "Name: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .users-table td:nth-child(3)::before { content: "Provider: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .users-table td:nth-child(6)::before { content: "Joined: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }

  /* Badge cells inline */
  .users-table td:nth-child(4),
  .users-table td:nth-child(5) {
    display: inline-block;
    margin-right: var(--space-md);
  }

  .providers-table td:nth-child(2)::before { content: "Slug: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .providers-table td:nth-child(4)::before { content: "Scale: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }
  .providers-table td:nth-child(5)::before { content: "Position: "; font-weight: 600; color: var(--color-text-muted); font-size: var(--font-size-sm); }

  /* Hide color swatch column on mobile */
  .providers-table td:nth-child(3) {
    display: none;
  }

  /* Actions row styling */
  .producers-table .actions,
  .providers-table .actions,
  .users-table .actions {
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-md);
    justify-content: flex-start;
  }

  /* Sync history card layout */
  .sync-history-table tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
  }

  .sync-error-row {
    display: block !important;
  }

  .sync-error-row td {
    display: block;
    padding: var(--space-md);
  }

  /* Bulk wines table */
  .wines-bulk-table {
    display: block;
    border: none;
  }

  .wines-bulk-table thead {
    display: none;
  }

  .wines-bulk-table tbody {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
  }

  .wines-bulk-table tbody tr {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--space-md) var(--space-lg);
  }

  .wines-bulk-table td {
    padding: 0;
    border: none;
  }

  .wines-bulk-table .checkbox-col {
    width: auto;
    flex-shrink: 0;
  }

  .wines-bulk-table td:nth-child(2) {
    flex: 1;
    min-width: 0;
  }

  .wines-bulk-table td:nth-child(4) {
    display: none;
  }

  /* --- Search Row --- */
  .search-row {
    flex-direction: column;
    align-items: stretch;
  }

  .search-row-actions {
    justify-content: flex-end;
  }

  /* --- Admin Forms --- */
  .search-form .search-input-wrapper {
    flex-direction: column;
  }

  .search-form .search-input {
    max-width: 100%;
  }

  .search-form .search-input-wrapper .btn {
    width: 100%;
  }

  .bulk-producer-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .producer-select-group {
    min-width: 0;
  }

  .producer-country-group,
  .producer-website-group {
    flex: 1 1 100%;
    min-width: 0;
  }

  .bulk-producer-actions {
    flex-direction: column;
  }

  .bulk-producer-actions .btn {
    width: 100%;
  }

  .sync-button-row {
    flex-wrap: wrap;
  }

  .sync-button-row .btn {
    flex: 1;
    min-width: calc(50% - var(--space-md));
    text-align: center;
  }

  .special-offer-link {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  /* --- Wine Detail Page --- */
  .wine-actions {
    flex-direction: column;
  }

  .wine-actions .btn {
    width: 100%;
  }
}

/* ===== Tablet: 2-column release cards ===== */
@media (min-width: 481px) and (max-width: 768px) {
  .releases-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
