/* responsive.css — Mobile breakpoints and responsive styles */

/* Tablet (≤1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 220px;
    --drawer-width: 340px;
  }

  .main-content {
    margin-left: 0;
  }

  /* Sidebar becomes overlay */
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    height: calc(100vh - var(--header-height));
    width: var(--sidebar-width);
    transform: translateX(-100%);
    z-index: 150;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Show overlay when sidebar is open */
  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
  }

  .sidebar-overlay.show {
    display: block;
  }

  /* Show menu toggle in header */
  .header-menu-toggle {
    display: flex;
  }

  /* Drawer narrower */
  .calc-drawer {
    width: var(--drawer-width);
  }
}

/* Mobile (≤768px) */
@media (max-width: 768px) {
  :root {
    --header-height: 56px;
    --spacing-lg: 16px;
    --spacing-xl: 24px;
    --font-size-xl: 20px;
  }

  /* Header adjustments */
  .header {
    padding: 0 var(--spacing-sm);
  }

  .header-logo span {
    display: none;
  }

  .header-actions {
    gap: var(--spacing-xs);
  }

  .header-link {
    display: none;
  }

  /* Main content full width */
  .main-content {
    margin-left: 0;
    padding-bottom: 60px; /* Space for bottom tabs */
  }

  /* Chat messages */
  .chat-messages {
    padding: var(--spacing-md) var(--spacing-sm);
  }

  .msg {
    gap: var(--spacing-sm);
  }

  .msg-avatar {
    width: 28px;
    height: 28px;
    font-size: 10px;
  }

  .msg-user .msg-body {
    max-width: 90%;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  /* Quick action cards */
  .quick-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }

  .quick-card {
    padding: var(--spacing-sm);
  }

  /* Welcome */
  .welcome {
    padding: var(--spacing-lg) var(--spacing-sm);
  }

  .welcome-icon {
    width: 48px;
    height: 48px;
  }

  .welcome-icon svg {
    width: 24px;
    height: 24px;
  }

  .welcome h2 {
    font-size: var(--font-size-lg);
  }

  .welcome p {
    font-size: var(--font-size-sm);
  }

  /* Input area */
  .input-area {
    padding: var(--spacing-sm);
  }

  .input-wrapper {
    gap: var(--spacing-xs);
  }

  .input-field {
    min-height: 40px;
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
  }

  .send-btn {
    width: 40px;
    height: 40px;
  }

  .input-hint {
    display: none;
  }

  /* Bottom tabs */
  .bottom-tabs {
    display: flex;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  /* Main content accounts for safe area */
  .main-content {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
  }

  /* Reference panel */
  .reference-content {
    padding: var(--spacing-sm);
  }

  .ref-cards {
    grid-template-columns: 1fr;
  }

  .ref-table {
    font-size: var(--font-size-xs);
  }

  .ref-table th,
  .ref-table td {
    padding: var(--spacing-xs);
  }

  /* Accordion */
  .accordion-header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .accordion-body {
    padding: var(--spacing-sm);
  }

  /* Calculator drawer becomes full-screen modal */
  .calc-drawer {
    display: none;
  }

  .calc-modal {
    display: none;
  }

  .calc-modal.open {
    display: flex;
  }

  /* Graco chart */
  .graco-chart {
    grid-template-columns: repeat(3, 1fr);
  }

  /* Coating system */
  .coating-layer {
    flex-direction: column;
    gap: var(--spacing-xs);
    text-align: center;
  }

  /* Follow-up suggestions */
  .followup-suggestions {
    gap: var(--spacing-xs);
  }

  .followup-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
  }

  /* Message actions */
  .msg-actions {
    gap: var(--spacing-xs);
  }

  .copy-btn,
  .regen-btn,
  .feedback-btn {
    padding: var(--spacing-xs);
  }

r
  /* Feedback buttons always visible on mobile (no hover) */
  .feedback-btn {
    opacity: 1;
  }

  /* Export menu: full-width fixed on mobile (like sessions menu) */
  .export-dropdown.open .export-menu {
    position: fixed;
    top: auto;
    bottom: 60px;
    left: 8px;
    right: 8px;
    min-width: auto;
    max-width: none;
  }
  .copy-btn span,
  .regen-btn span {
    display: none;
  }

  /* Product cards */
  .product-card {
    padding: var(--spacing-sm);
    gap: var(--spacing-sm);
  }

  .product-card-name {
    font-size: var(--font-size-sm);
  }

  .product-card-price {
    font-size: var(--font-size-sm);
  }
}

/* Small mobile (≤480px) */
@media (max-width: 480px) {
  :root {
    --spacing-md: 12px;
    --font-size-md: 14px;
    --font-size-sm: 12px;
    --font-size-xs: 10px;
  }

  .header-logo svg {
    width: 28px;
    height: 28px;
  }

  .msg-avatar {
    width: 24px;
    height: 24px;
  }

  .welcome-icon {
    width: 40px;
    height: 40px;
  }

  .quick-card-title {
    font-size: var(--font-size-xs);
  }

  .quick-card-items li {
    font-size: var(--font-size-xs);
  }

  /* Ref tables scroll */
  .accordion-body {
    overflow-x: auto;
  }

  .ref-table {
    min-width: 500px;
  }

  /* Graco chart smaller */
  .graco-chart {
    grid-template-columns: repeat(2, 1fr);
  }

  .graco-tip {
    padding: var(--spacing-xs);
  }

  .graco-tip-code {
    font-size: var(--font-size-md);
  }

  /* Calculator form */
  .calc-row {
    margin-bottom: var(--spacing-sm);
  }

  .calc-input,
  .calc-select {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
  }

  .calc-btn {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-sm);
  }

  .result-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .header {
    --header-height: 48px;
  }

  .welcome {
    padding: var(--spacing-md);
  }

  .welcome-icon {
    width: 40px;
    height: 40px;
    margin-bottom: var(--spacing-sm);
  }

  .quick-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .bottom-tabs {
    height: 48px;
  }

  .bottom-tab svg {
    width: 18px;
    height: 18px;
  }

  .bottom-tab span {
    font-size: 9px;
  }
}

/* Print styles */
@media print {
  .header,
  .sidebar,
  .bottom-tabs,
  .calc-drawer,
  .input-area,
  .msg-actions,
  .followup-suggestions {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
  }

  .chat-messages {
    max-width: none;
  }

  .msg {
    break-inside: avoid;
  }

  .ref-table {
    font-size: 10pt;
  }
}

/* Dark mode specific responsive adjustments */
html.dark {
  /* Overlay darker in dark mode */
  .sidebar-overlay.show {
    background: rgba(0, 0, 0, 0.7);
  }

  /* Select dropdown icon for dark mode */
  .calc-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  :root {
    --border: #000;
    --text-secondary: #333;
  }

  html.dark {
    --border: #fff;
    --text-secondary: #ccc;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .chat-area {
    scroll-behavior: auto;
  }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  .quick-card-items li {
    padding: var(--spacing-sm) 0;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .accordion-header {
    min-height: 48px;
  }

  .calc-header {
    min-height: 48px;
  }

  .calc-preset {
    min-height: 36px;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  /* Remove hover effects */
  .quick-card:hover,
  .accordion-header:hover,
  .calc-header:hover {
    transform: none;
  }
r
  /* Chat button touch targets */
  .feedback-btn {
    opacity: 1;
    min-width: 36px;
    min-height: 36px;
  }

  .voice-btn {
    min-width: 44px;
    min-height: 44px;
  }

  .msg-actions .copy-btn,
  .msg-actions .regen-btn {
    min-width: 36px;
    min-height: 36px;
  }

  /* Message actions always visible on touch */
  .msg-actions {
    opacity: 1;
  }
}
