/*
 * Mobile Overrides
 * All mobile-specific styles consolidated in one file.
 * Breakpoint: 768px
 */

/* ===== Hamburger Button ===== */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: var(--tap-target-min);
  height: var(--tap-target-min);
  padding: 10px;
  background: none;
  border: none;
  cursor: pointer;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform 0.3s, opacity 0.3s;
}

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

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

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

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

  .nav-links {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: var(--color-bg-card);
    flex-direction: column;
    padding: var(--space-xl) var(--space-lg);
    gap: 0;
    z-index: 200;
    overflow-y: auto;
    transition: right 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

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

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

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

  /* Animated hamburger -> X */
  .hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(2) {
    opacity: 0;
  }

  .hamburger-btn[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

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

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

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

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

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

  /* --- Touch Targets --- */
  .btn,
  a.btn,
  input[type="submit"].btn,
  button.btn {
    min-height: var(--tap-target-min);
    padding: var(--space-sm) var(--space-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn-small {
    min-height: var(--tap-target-min);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
  }

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

  .filter-btn {
    min-height: var(--tap-target-min);
    padding: var(--space-sm) var(--space-md);
  }

  .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-sm);
  }

  .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-md);
  }

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

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

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

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

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

  .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-lg);
  }

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

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

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

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

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

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

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

  /* --- 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-md);
  }

  .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-md);
    padding: var(--space-md);
  }

  .producers-table td,
  .providers-table td,
  .users-table td,
  .sync-history-table td,
  .reviews-table td {
    display: block;
    padding: var(--space-xs) 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-lg);
    font-weight: 600;
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--space-sm);
  }

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

  .users-table td:nth-child(2)::before { content: "Name: "; font-weight: 600; color: var(--color-text-light); font-size: var(--font-size-sm); }
  .users-table td:nth-child(3)::before { content: "Provider: "; font-weight: 600; color: var(--color-text-light); font-size: var(--font-size-sm); }
  .users-table td:nth-child(6)::before { content: "Joined: "; font-weight: 600; color: var(--color-text-light); 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-sm);
  }

  .providers-table td:nth-child(2)::before { content: "Slug: "; font-weight: 600; color: var(--color-text-light); font-size: var(--font-size-sm); }
  .providers-table td:nth-child(4)::before { content: "Scale: "; font-weight: 600; color: var(--color-text-light); font-size: var(--font-size-sm); }
  .providers-table td:nth-child(5)::before { content: "Position: "; font-weight: 600; color: var(--color-text-light); 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-sm);
    border-top: 1px solid var(--color-border);
    margin-top: var(--space-sm);
    justify-content: flex-start;
  }

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

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

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

  /* 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-sm);
  }

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

  .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;
  }

  /* --- 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;
  }

  .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-sm));
    text-align: center;
  }

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

  /* --- 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);
  }
}
