/* ============================================================
   Villa Kleineh Project — Detail Panel Styles
   ============================================================ */

/* -------------------------
   Layout Container (New)
   ------------------------- */
.detail-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height) - var(--footer-height));
  height: calc(100vh - var(--header-height) - var(--footer-height));
  background: var(--bg-body);
  overflow: hidden;
}

@media (min-width: 768px) {
  body.view-detail {
    overflow: hidden;
  }

  body.view-detail .main {
    margin-top: 0;
    padding: 0;
    padding-top: var(--header-height);
    height: calc(100vh - var(--header-height) - var(--footer-height));
    overflow: hidden;
  }

  body.view-detail .detail-layout {
    height: 100%;
    min-height: 0;
  }

  body.view-detail .detail-gallery {
    min-height: 0;
  }
}

/* -------------------------
   Gallery (Center Stage)
   ------------------------- */
.detail-gallery {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: var(--space-4);
  min-width: 0;
  overflow: hidden;
  margin-right: 400px; /* Space for fixed sidebar */
  max-height: calc(100vh - var(--header-height) - var(--footer-height, 0));
}

.detail-gallery__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: var(--space-3);
  padding: 0 var(--space-2);
  flex-shrink: 0;
}

.detail-gallery__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--text-primary);
}

.detail-gallery__title svg {
  width: 20px;
  height: 20px;
}

.detail-gallery__count {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* Navigation buttons - centered row above gallery */
.detail-gallery__nav-buttons {
  display: flex;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-4) 0;
  flex-shrink: 0;
}

.detail-gallery__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-width: 100px;
  padding: var(--space-2) var(--space-4);
  background: transparent;
  border: 2px solid var(--color-primary);
  border-radius: 9999px; /* Pill shape */
  color: var(--text-primary);
  text-decoration: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  transition: all var(--transition-fast);
}

.detail-gallery__btn:hover {
  background: rgba(0, 163, 255, 0.15);
  border-color: var(--color-primary);
  color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 163, 255, 0.2);
}

.detail-gallery__btn svg {
  width: 16px;
  height: 16px;
}

.detail-gallery__carousel {
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.detail-gallery__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-8);
  color: var(--text-muted);
  font-size: var(--font-size-base);
  text-align: center;
}

.detail-gallery__empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.5;
}

/* -------------------------
   Sidebar (Right Panel - Fixed)
   ------------------------- */
.detail-sidebar {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: var(--footer-height, 0);
  width: 400px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 50;
  /* Hide scrollbar for Webkit */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE/Edge */
}

.detail-sidebar::-webkit-scrollbar {
  display: none;
}

.detail-sidebar__header {
  position: sticky;
  top: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color-subtle);
  z-index: 2;
}

/* Navigation buttons have been moved to .detail-gallery__header */

.detail-sidebar__location {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.detail-sidebar__location-id {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.detail-sidebar__location-id svg {
  width: 20px;
  height: 20px;
}

.detail-sidebar__breadcrumb {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.detail-sidebar__content {
  flex: 1;
  overflow-y: auto;
  /* Hide scrollbar */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.detail-sidebar__content::-webkit-scrollbar {
  display: none;
}

/* -------------------------
   Legacy Panel (kept for compatibility)
   ------------------------- */
.detail-panel {
  position: fixed;
  top: var(--header-height);
  right: 0;
  bottom: var(--footer-height);
  width: 420px;
  max-width: 100vw;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-color);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

.detail-panel--open {
  transform: translateX(0);
}

/* Overlay for mobile */
.detail-panel-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 89;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-base), visibility var(--transition-base);
}

.detail-panel-overlay--visible {
  opacity: 1;
  visibility: visible;
}

/* -------------------------
   Panel Header
   ------------------------- */
.detail-panel__header {
  position: sticky;
  top: 0;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color-subtle);
  z-index: 2;
}

.detail-panel__header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.detail-panel__location {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.detail-panel__close {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.25rem;
  transition: transform var(--transition-fast), background-color var(--transition-fast), color var(--transition-fast);
}

.detail-panel__close:hover {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: white;
  transform: scale(1.05);
}

.detail-panel__breadcrumb {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

/* -------------------------
   Photo Gallery
   ------------------------- */
.detail-panel__gallery {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}

.detail-panel__gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.detail-panel__gallery-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.detail-panel__gallery-count {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Main carousel image */
.gallery-carousel {
  position: relative;
  flex: 1;
  min-height: 200px;
  max-height: calc(100vh - var(--header-height) - var(--footer-height, 0) - 200px);
  display: flex;
  flex-direction: column;
}

.gallery-carousel__main {
  width: 100%;
  flex: 1;
  min-height: 200px;
  max-height: 100%;
  background: var(--bg-body);
  border-radius: var(--border-radius-lg, 12px);
  overflow: hidden;
  cursor: zoom-in;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-carousel__main img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  background: var(--bg-body);
  transition: transform var(--transition-base);
  display: block;
  margin: 0 auto;
}

.gallery-carousel__main:hover img {
  transform: scale(1.02);
}

/* Carousel navigation buttons */
.gallery-carousel__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  color: var(--text-primary);
  font-size: 1rem;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
  z-index: 1;
}

.gallery-carousel__nav:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.gallery-carousel__nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.gallery-carousel__nav--prev {
  left: var(--space-2);
}

.gallery-carousel__nav--next {
  right: var(--space-2);
}

/* Thumbnail strip */
.gallery-thumbnails {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3) 0;
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
}

.gallery-thumbnails::-webkit-scrollbar {
  height: 4px;
}

.gallery-thumbnails::-webkit-scrollbar-track {
  background: var(--bg-surface-elevated);
  border-radius: 2px;
}

.gallery-thumbnails::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.gallery-thumbnail {
  flex-shrink: 0;
  width: 80px;
  height: 60px;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  opacity: 0.6;
  transition: all var(--transition-fast);
}

.gallery-thumbnail:hover {
  opacity: 1;
  transform: scale(1.05);
}

.gallery-thumbnail--active {
  border-color: var(--color-primary);
  opacity: 1;
}

.gallery-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* -------------------------
   Upload Status Overlays
   ------------------------- */

/* Uploading state - pulsing animation */
.gallery-thumbnail--uploading {
  position: relative;
  opacity: 0.8;
  border-color: var(--color-primary);
}

.gallery-thumbnail--uploading::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1;
  animation: pulse-overlay 1.5s ease-in-out infinite;
}

.gallery-thumbnail--uploading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  z-index: 2;
  animation: spin 0.8s linear infinite;
}

@keyframes pulse-overlay {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.7; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Failed state - error indicator */
.gallery-thumbnail--failed {
  position: relative;
  border-color: var(--color-danger);
  opacity: 0.9;
}

.gallery-thumbnail--failed::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(220, 38, 38, 0.4);
  z-index: 1;
}

.gallery-thumbnail__retry {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  z-index: 2;
  cursor: pointer;
  background: transparent;
  border: none;
  color: white;
  font-size: 10px;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
}

.gallery-thumbnail__retry svg {
  width: 20px;
  height: 20px;
}

.gallery-thumbnail__retry:hover {
  background: rgba(0, 0, 0, 0.3);
}

/* Progress bar */
.gallery-thumbnail__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3;
  overflow: hidden;
}

.gallery-thumbnail__progress-bar {
  height: 100%;
  background: var(--color-primary);
  transition: width 0.15s ease-out;
  box-shadow: 0 0 6px var(--color-primary);
}

/* Empty state */
.gallery-empty {
  padding: var(--space-5);
  text-align: center;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* -------------------------
   Panel Sections
   ------------------------- */
.detail-panel__section {
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}

.detail-panel__section:last-child {
  border-bottom: none;
}

.detail-panel__section-header {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
}

/* -------------------------
   Categories (Checkboxes)
   ------------------------- */
.categories-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.category-chip {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--bg-surface-elevated);
  border-radius: 9999px;
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
}

.category-chip--checked {
  background: rgba(0, 163, 255, 0.15);
  color: var(--color-primary);
}

.category-chip__icon {
  font-size: 0.75rem;
}

/* -------------------------
   Work Categories (Table)
   ------------------------- */
.work-categories__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.work-categories__header .detail-panel__section-header {
  margin-bottom: 0;
}

.work-categories__add-column {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--font-size-xs);
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.work-categories__add-column svg {
  width: 14px;
  height: 14px;
}

.work-categories__add-column:hover {
  color: var(--color-primary);
  border-color: rgba(0, 163, 255, 0.4);
  background: rgba(0, 163, 255, 0.08);
}

.work-categories__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.work-categories__select {
  flex: 1;
}

.work-categories__select-input {
  width: 100%;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
}

.work-categories__select-input:focus,
.work-categories__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px rgba(0, 163, 255, 0.35);
}

.work-categories__add-custom {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.work-categories__add-custom svg {
  width: 16px;
  height: 16px;
}

.work-categories__add-custom:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(0, 163, 255, 0.08);
}

.work-categories__custom {
  display: none;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.work-categories__custom.is-visible {
  display: flex;
}

.work-categories__input {
  flex: 1;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
}

.work-categories__custom-submit {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.work-categories__custom-submit:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: rgba(0, 163, 255, 0.08);
}

.work-categories__table-wrapper {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  overflow: auto;
  background: var(--bg-surface-elevated);
}

.work-categories__table {
  width: 100%;
  border-collapse: collapse;
}

.work-categories__table thead th {
  text-align: left;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-color);
}

.work-categories__table tbody td {
  padding: var(--space-2) var(--space-3);
  border-top: 1px solid var(--border-color);
}

.work-categories__table tbody tr:first-child td {
  border-top: none;
}

.work-categories__cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  padding: var(--space-1) 0;
}

.work-categories__cell-input:focus {
  outline: none;
  border-color: var(--color-primary);
  background: rgba(0, 163, 255, 0.08);
  border-radius: 6px;
  padding: var(--space-1) var(--space-2);
}

.work-categories__empty {
  padding: var(--space-3);
  border: 1px dashed var(--border-color);
  border-radius: var(--border-radius);
  text-align: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

.work-categories__status {
  margin-top: var(--space-2);
  min-height: 1em;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* -------------------------
   Status Indicator
   ------------------------- */
.status-indicator {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.status-badge {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--border-radius);
  font-size: var(--font-size-sm);
  font-weight: 500;
}

.status-badge--not_started {
  background: rgba(209, 213, 219, 0.15);
  color: var(--status-not-started);
}

.status-badge--documented {
  background: rgba(251, 146, 60, 0.15);
  color: var(--status-documented);
}

.status-badge--priced {
  background: rgba(56, 189, 248, 0.15);
  color: var(--status-priced);
}

.status-badge--complete {
  background: rgba(74, 222, 128, 0.15);
  color: var(--status-complete);
}

.status-badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.reviewed-badge {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: rgba(74, 222, 128, 0.15);
  border-radius: var(--border-radius);
  font-size: var(--font-size-xs);
  color: var(--status-complete);
}

/* -------------------------
   Notes Section
   ------------------------- */
.notes-content {
  background: var(--bg-body);
  border-radius: var(--border-radius);
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  line-height: 1.6;
}

.notes-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* -------------------------
   Tags Section
   ------------------------- */
.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.tag {
  padding: var(--space-1) var(--space-2);
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* -------------------------
   Pricing Table
   ------------------------- */
.pricing-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.pricing-table th {
  text-align: left;
  padding: var(--space-2);
  background: var(--bg-body);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pricing-table td {
  padding: var(--space-2);
  border-top: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.pricing-table__total {
  font-weight: 600;
  color: var(--text-primary);
}

.pricing-empty {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

/* -------------------------
   Comments Section
   ------------------------- */
.comments-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.comment {
  background: var(--bg-body);
  border-radius: var(--border-radius);
  padding: var(--space-3);
}

.comment__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.comment__author {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.comment__date {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  flex: 1;
}

.comment__actions {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.comment__edit,
.comment__delete {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--border-radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0.6;
}

.comment__edit:hover {
  opacity: 1;
  color: var(--color-primary);
  border-color: var(--color-primary);
  background: rgba(0, 163, 255, 0.1);
}

.comment__delete:hover {
  opacity: 1;
  color: var(--color-error);
  border-color: var(--color-error);
  background: rgba(239, 68, 68, 0.1);
}

.comment__edit svg,
.comment__delete svg {
  width: 14px;
  height: 14px;
}

.comment__text {
  font-size: var(--font-size-sm);
  color: #f97316; /* Orange for visibility */
  line-height: 1.5;
}

.comments-empty {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  font-style: italic;
}

/* Comment count in tables - orange for visibility */
.comment-count {
  color: #f97316;
  font-weight: 600;
}

/* -------------------------
   Notes Editor (Editable)
   ------------------------- */
.notes-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.notes-editor__input {
  width: 100%;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--text-primary);
  line-height: 1.6;
  resize: vertical;
  min-height: 80px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.notes-editor__input::placeholder {
  color: var(--text-muted);
}

.notes-editor__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.notes-editor__status {
  min-height: 1em;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* -------------------------
   Comment Form (Add Comment)
   ------------------------- */
.comment-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}

.comment-form__input {
  width: 100%;
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  font-family: inherit;
  color: var(--text-primary);
  line-height: 1.5;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.comment-form__input::placeholder {
  color: var(--text-muted);
}

.comment-form__input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.comment-form__submit {
  align-self: flex-end;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
  border: none;
  border-radius: var(--border-radius);
  color: #000;
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
}

.comment-form__submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--color-primary-glow);
}

.comment-form__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.comment-form__submit svg {
  width: 16px;
  height: 16px;
}

.comment-form__status {
  min-height: 1em;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* -------------------------
   Responsive - New Layout
   ------------------------- */

/* Tablet (768-1023px) */
@media (max-width: 1023px) {
  .detail-sidebar {
    width: 360px;
  }

  .detail-gallery {
    margin-right: 360px;
    padding: var(--space-3);
  }
}

/* Mobile (<768px) - Stack layout */
@media (max-width: 767px) {
  .detail-layout {
    flex-direction: column;
    min-height: auto;
    height: auto;
    overflow: visible;
  }

  .detail-gallery {
    margin-right: 0;
    padding: var(--space-3);
    min-height: 60vh;
    height: auto;
    max-height: 70vh;
  }

  .detail-sidebar {
    position: relative;
    top: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    max-height: none;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }

  .detail-sidebar__header {
    position: relative;
  }

  .detail-gallery__nav-buttons {
    padding: var(--space-2) 0;
    gap: var(--space-2);
  }

  .detail-gallery__btn {
    min-width: 0;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
  }

  .detail-gallery__btn svg {
    width: 16px;
    height: 16px;
  }
}

/* Extra small mobile */
@media (max-width: 479px) {
  .detail-gallery {
    padding: var(--space-2);
    min-height: 50vh;
    height: 50vh;
  }

  .detail-gallery__title {
    font-size: var(--font-size-base);
  }

  .detail-sidebar__location-id {
    font-size: var(--font-size-lg);
  }
}

/* -------------------------
   Responsive - Legacy Panel
   ------------------------- */
@media (max-width: 767px) {
  .detail-panel {
    width: 100%;
    left: 0;
    top: 0;
    bottom: 0;
    border-left: none;
  }

  .detail-panel__header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: var(--space-4);
    padding-top: calc(var(--header-height) + var(--space-4));
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .detail-panel__gallery {
    margin-top: calc(var(--header-height) + 80px);
  }

  .detail-panel__close {
    width: 44px;
    height: 44px;
    font-size: 1.5rem;
  }

  .gallery-carousel__nav {
    width: 48px;
    height: 48px;
  }

  .gallery-thumbnails {
    padding-bottom: var(--space-2);
  }

  .gallery-thumbnail {
    width: 80px;
    height: 60px;
  }

  .detail-panel__section {
    padding: var(--space-3);
  }
}

/* Extra small mobile */
@media (max-width: 479px) {
  .detail-panel__header {
    padding: var(--space-3);
    padding-top: calc(var(--header-height) + var(--space-3));
  }

  .detail-panel__location {
    font-size: var(--font-size-lg);
  }

  .gallery-carousel__main {
    aspect-ratio: 1;
  }

  .category-chip {
    font-size: 10px;
    padding: 2px 6px;
  }
}

/* -------------------------
   Mobile Portrait Optimizations
   ------------------------- */
@media (max-width: 480px) and (orientation: portrait) {
  /* Gallery optimizations - reduce glitches */
  .gallery-carousel__main {
    /* Hardware acceleration for smoother transitions */
    transform: translateZ(0);
    will-change: contents;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .gallery-carousel__main img {
    /* Smooth image switching */
    will-change: opacity, src;
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Prevent image flicker */
    image-rendering: -webkit-optimize-contrast;
  }

  /* Larger touch targets for nav buttons */
  .gallery-carousel__nav {
    width: 52px;
    height: 52px;
    touch-action: manipulation;
  }

  /* Optimize thumbnail scrolling */
  .gallery-thumbnails {
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
  }

  .gallery-thumbnail {
    scroll-snap-align: center;
    touch-action: manipulation;
    /* Prevent tap delay */
    -webkit-tap-highlight-color: transparent;
  }

  /* Reduce animation complexity on mobile */
  .gallery-thumbnail--uploading::before {
    animation: none;
    opacity: 0.6;
  }

  /* Pill buttons - ensure good touch targets */
  .detail-gallery__btn,
  .view__nav-btn {
    min-height: 44px;
    padding: var(--space-2) var(--space-4);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  /* Photo viewer sidebar - stack vertically on mobile portrait */
  .single-photo-viewer__content {
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    max-width: none;
  }
}

/* -------------------------
   Tables Page - Mobile Portrait
   ------------------------- */
@media (max-width: 480px) and (orientation: portrait) {
  /* Make tables horizontally scrollable */
  .work-categories__table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .work-categories__table {
    min-width: 280px;
  }

  .work-categories__table thead th,
  .work-categories__table tbody td {
    padding: var(--space-2);
    font-size: var(--font-size-xs);
    white-space: nowrap;
  }

  .work-categories__cell-input {
    font-size: 16px; /* Prevent iOS zoom on focus */
    min-height: 36px;
  }

  /* Comments section */
  .comment__text {
    font-size: var(--font-size-sm);
  }

  /* Notes textarea */
  .notes-textarea {
    font-size: 16px; /* Prevent iOS zoom */
    min-height: 80px;
  }
}

/* -------------------------
   Details Page - Mobile Portrait
   ------------------------- */
@media (max-width: 480px) and (orientation: portrait) {
  /* Reduce padding for more content space */
  .detail-panel__section {
    padding: var(--space-2);
  }

  .detail-panel__section-header {
    font-size: var(--font-size-xs);
    margin-bottom: var(--space-2);
  }

  /* Stack status indicators */
  .status-indicator {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  /* Smaller category chips */
  .categories-list {
    gap: var(--space-1);
  }

  .category-chip {
    font-size: 9px;
    padding: 2px 5px;
  }
}

/* -------------------------
   Home/Landing Page - Mobile Portrait  
   ------------------------- */
@media (max-width: 480px) and (orientation: portrait) {
  /* Facade cards - single column */
  .landing__facades {
    grid-template-columns: 1fr;
    gap: var(--space-3);
    max-width: 280px;
  }

  .facade-card {
    padding: var(--space-3);
  }

  .facade-card__title {
    font-size: var(--font-size-base);
  }

  /* Reduce 3D model container on mobile */
  .three-container {
    max-height: 35vh;
  }
}
