/* ===================================================================
   Image Editor Studio Pro - Responsive & Breakpoints Styling
   Engineered for seamless desktop, tablet, and mobile workflows
   =================================================================== */

/* Default Visibility for Mobile-Only / Desktop-Only Components */
.mobile-only-btn {
  display: none !important;
}

.desktop-only-action {
  display: inline-flex;
}

.desktop-only-inline {
  display: inline-flex;
}

.flyout-close-btn {
  display: none;
}

.right-dock-mobile-header {
  display: none;
}

.mobile-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
}

/* Touch Action Optimization for Canvas */
#canvas-stage,
#main-canvas,
#overlay-canvas {
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* Mobile Drawer Backdrop (For Flyout & Right Dock) */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.mobile-drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile Menu Backdrop & Drawer */
.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.mobile-menu-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 310px;
  max-width: 86vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-light);
  box-shadow: var(--shadow-lg);
  z-index: 110;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

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

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

.mobile-drawer-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

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

.mobile-nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-md);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  background: var(--bg-surface-elevated);
  border-color: var(--primary-light);
  color: #ffffff;
  box-shadow: 0 0 12px var(--primary-glow);
}

.mobile-actions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-action-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg-dark);
  border: 1px solid var(--border-subtle);
  border-radius: var(--border-radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.mobile-action-item:hover,
.mobile-action-item:active {
  background: var(--bg-hover);
  border-color: var(--border-light);
  color: var(--primary-light);
}

.mobile-action-item svg {
  color: var(--primary-light);
  flex-shrink: 0;
}

/* ===================================================================
   Large Tablets & Medium Desktops (max-width: 1200px)
   =================================================================== */
@media (max-width: 1200px) {
  .batch-workspace {
    grid-template-columns: 1fr 300px;
    gap: 16px;
  }
}

/* ===================================================================
   Tablets & Landscape Mobile (max-width: 1024px)
   =================================================================== */
@media (max-width: 1024px) {
  .right-dock {
    width: 260px;
  }
  .tool-flyout {
    width: 270px;
  }
  .batch-workspace {
    grid-template-columns: 1fr;
  }
  .header-actions .btn-secondary span {
    display: none;
  }
}

/* ===================================================================
   Smartphones & Portrait Tablets (max-width: 860px)
   =================================================================== */
@media (max-width: 860px) {
  /* Header Adaptation */
  .app-header {
    height: 52px;
    min-height: 52px;
    padding: 0 10px;
    padding-top: env(safe-area-inset-top, 0px);
  }

  .brand-badge {
    display: none;
  }

  .brand-name {
    font-size: 14px;
  }

  /* Hide Desktop Workspace Tabs on Header */
  .nav-tabs {
    display: none;
  }

  /* Show Mobile Action Toggles */
  .mobile-only-btn {
    display: inline-flex !important;
    position: relative;
  }

  .desktop-only-action {
    display: none !important;
  }

  .header-actions {
    gap: 6px;
  }

  #btn-header-export {
    padding: 6px 12px;
    font-size: 12px;
  }

  /* Main Studio Layout: Vertical Stack */
  .studio-container {
    flex-direction: column;
    height: calc(100vh - 52px);
    height: calc(100dvh - 52px);
  }

  /* Horizontal Tool Dock */
  .tool-dock {
    width: 100%;
    height: 56px;
    min-height: 56px;
    flex-direction: row;
    padding: 0 10px;
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    justify-content: flex-start;
    align-items: center;
    order: 1; /* Dock placed right under header */
  }

  /* Hide scrollbars for tool dock */
  .tool-dock::-webkit-scrollbar {
    display: none;
  }
  .tool-dock {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .tool-btn {
    width: 48px;
    height: 46px;
    min-width: 48px;
    border-radius: var(--border-radius-sm);
    gap: 1px;
    flex-shrink: 0;
  }

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

  .tool-btn span {
    font-size: 8.5px;
    display: block;
    max-width: 46px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tool-btn.active::before {
    display: none;
  }

  .tool-btn.active {
    background: var(--bg-surface-elevated);
    border-bottom: 2px solid var(--primary-light);
    box-shadow: 0 0 10px var(--primary-glow);
  }

  .tool-divider {
    width: 1px;
    height: 28px;
    margin: 0 4px;
    flex-shrink: 0;
  }

  /* Viewport Container takes remaining space */
  .viewport-container {
    order: 2;
    flex: 1;
    height: auto;
    min-height: 0;
  }

  /* Viewport Preset Pills Bar */
  .viewport-bar {
    height: 36px;
    padding: 0 10px;
  }

  .preset-pills {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    gap: 4px;
    padding: 2px 0;
  }

  .preset-pills::-webkit-scrollbar {
    display: none;
  }
  .preset-pills {
    scrollbar-width: none;
  }

  .preset-pill-btn {
    padding: 3px 8px;
    font-size: 10px;
    flex-shrink: 0;
  }

  .canvas-dimension-info {
    font-size: 10px;
    white-space: nowrap;
  }

  /* Viewport Bottom Controls Bar */
  .viewport-bottom-bar {
    height: 42px;
    padding: 0 10px;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .zoom-controls {
    gap: 6px;
  }

  .zoom-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .zoom-display {
    font-size: 10px;
    min-width: 36px;
  }

  .desktop-tips {
    display: none !important;
  }

  /* Off-Canvas Tool Flyout (Drawer Sheet) */
  .tool-flyout {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 320px;
    max-width: 88vw;
    height: 100%;
    z-index: 85;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-light);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

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

  .flyout-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
  }

  /* Off-Canvas Right Dock (Layers & History Drawer) */
  .right-dock {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    max-width: 88vw;
    height: 100%;
    z-index: 85;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-light);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

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

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

  .right-tab-btn {
    padding: 12px 6px;
    font-size: 13px;
  }

  /* Canvas Empty Dropzone on Tablet/Mobile */
  .canvas-empty-state {
    inset: 16px;
    padding: 16px;
  }

  .empty-title {
    font-size: 16px;
    text-align: center;
  }

  .empty-subtitle {
    font-size: 12px;
  }

  /* Batch Hub Responsive Styles */
  .batch-container {
    padding: 14px 10px;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .batch-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
  }

  .batch-hero h1 {
    font-size: 1.35rem;
    line-height: 1.3;
  }

  .batch-hero p {
    font-size: 12px;
  }

  .batch-tool-pills {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    gap: 6px;
  }

  .batch-tool-pills::-webkit-scrollbar {
    display: none;
  }

  .batch-tool-pill {
    padding: 8px 12px;
    font-size: 12px;
    flex-shrink: 0;
  }

  .batch-workspace {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .batch-cards-container {
    grid-template-columns: 1fr;
  }

  .batch-config-panel {
    width: 100%;
  }

  /* SEO Guide Responsive Styles */
  .seo-guide-container {
    padding: 20px 14px;
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  }

  .seo-header .seo-h1 {
    font-size: 1.5rem;
    line-height: 1.3;
  }

  .seo-lead {
    font-size: 13px;
  }

  .seo-badge-row {
    gap: 6px;
  }

  .seo-pill, .seo-pill-accent {
    font-size: 10px;
    padding: 3px 8px;
  }

  .seo-cards-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .seo-table-container {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--border-radius-sm);
  }

  .seo-table {
    min-width: 540px;
    font-size: 12px;
  }

  .seo-table th, .seo-table td {
    padding: 8px 10px;
  }

  .seo-cta-card {
    padding: 20px 16px;
  }

  .seo-cta-actions {
    flex-direction: column;
    width: 100%;
  }

  .seo-cta-actions .btn {
    width: 100%;
  }
}

/* ===================================================================
   Small Phones (max-width: 480px)
   =================================================================== */
@media (max-width: 480px) {
  .brand-logo .brand-text {
    display: none; /* Icon-only logo on ultra-narrow screens */
  }

  .header-actions {
    gap: 4px;
  }

  #btn-header-export {
    padding: 5px 10px;
  }
  
  #btn-header-export span {
    display: none; /* Show export icon only to maximize space */
  }

  .viewport-bar {
    padding: 0 6px;
  }

  .canvas-dimension-info {
    display: none; /* Give aspect pills full width */
  }

  .desktop-only-inline {
    display: none !important;
  }

  .samples-row {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .batch-file-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .card-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .card-name {
    max-width: 200px;
  }

  /* Modal Sheet full-bleed on small phones */
  .modal-overlay {
    padding: 10px;
  }

  .modal-container {
    width: 100%;
    max-height: 92vh;
    border-radius: var(--border-radius-md);
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    padding: 14px 16px;
    gap: 14px;
  }

  .modal-footer {
    padding: 12px 16px;
  }

  /* Toast notification on mobile */
  .toast-container {
    bottom: 60px;
    right: 12px;
    left: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .toast {
    width: 100%;
    max-width: 360px;
  }
}
