/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f5f5f7;
  color: #1d1d1f;
  min-height: 100vh;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
  background: #fff;
  border-bottom: 1px solid #e5e5e7;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.3px;
}

.account-badge {
  display: none;
  background: #e8f0fe;
  color: #1a73e8;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

/* ── Toolbar ──────────────────────────────────────────── */
.toolbar {
  background: #fff;
  border-bottom: 1px solid #e5e5e7;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-input {
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  width: 260px;
  max-width: 100%;
  outline: none;
  transition: border-color .15s;
}

.search-input:focus {
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}

.type-filter {
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  background: #fff;
  outline: none;
  cursor: pointer;
}

.type-filter:focus {
  border-color: #1a73e8;
}

.record-count {
  font-size: 13px;
  color: #86868b;
  white-space: nowrap;
}

.view-toggle {
  display: flex;
  background: #f0f0f2;
  border-radius: 8px;
  overflow: hidden;
}

.view-btn {
  background: none;
  border: none;
  padding: 7px 10px;
  cursor: pointer;
  color: #86868b;
  display: flex;
  align-items: center;
  transition: all .15s;
}

.view-btn.active {
  background: #fff;
  color: #1d1d1f;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.view-btn:hover:not(.active) {
  color: #1d1d1f;
}

/* ── Status Bar ───────────────────────────────────────── */
.status-bar {
  padding: 40px 24px;
  text-align: center;
  color: #86868b;
  font-size: 14px;
}

/* ── No Account Message ───────────────────────────────── */
.no-account-msg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px;
}

.no-account-inner {
  text-align: center;
  max-width: 360px;
}

.no-account-inner svg {
  margin-bottom: 16px;
}

.no-account-inner h2 {
  font-size: 20px;
  font-weight: 600;
  color: #1d1d1f;
  margin-bottom: 8px;
}

.no-account-inner p {
  color: #86868b;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Content ──────────────────────────────────────────── */
.content {
  padding: 24px;
}

/* ── Gallery View ─────────────────────────────────────── */
.logo-grid.view-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.logo-card {
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #e5e5e7;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}

.logo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}

.card-preview {
  width: 100%;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(45deg, #f0f0f2 25%, transparent 25%),
    linear-gradient(-45deg, #f0f0f2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f0f0f2 75%),
    linear-gradient(-45deg, transparent 75%, #f0f0f2 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #fafafa;
  padding: 20px;
  position: relative;
}

.card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-preview.img-error::after {
  content: 'Preview unavailable';
  position: absolute;
  color: #999;
  font-size: 12px;
}

.no-preview {
  color: #ccc;
  font-size: 13px;
}

.card-info {
  padding: 12px 14px 14px;
  border-top: 1px solid #f0f0f2;
}

.card-code {
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
  font-family: 'SF Mono', 'Menlo', monospace;
  margin-bottom: 4px;
}

.card-name {
  font-size: 13px;
  color: #86868b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 4px;
}

/* ── Type Badges ──────────────────────────────────────── */
.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.type-embroidery { background: #dbeafe; color: #1d4ed8; }
.type-printing { background: #dcfce7; color: #16a34a; }
.type-laser { background: #ffedd5; color: #ea580c; }
.type-uv { background: #ede9fe; color: #7c3aed; }
.type-heat { background: #fee2e2; color: #dc2626; }
.type-default { background: #f0f0f2; color: #666; }

/* ── List View ────────────────────────────────────────── */
.logo-grid.view-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff;
  border-radius: 12px;
  border: 1px solid #e5e5e7;
  overflow: hidden;
}

.logo-row {
  display: grid;
  grid-template-columns: 48px 120px 1fr 120px 60px 100px 60px;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background .1s;
  border-bottom: 1px solid #f0f0f2;
}

.logo-row:last-child {
  border-bottom: none;
}

.logo-row:hover {
  background: #f8f8fa;
}

.row-thumb {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  border-radius: 6px;
  overflow: hidden;
}

.row-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.row-code {
  font-size: 13px;
  font-weight: 600;
  font-family: 'SF Mono', 'Menlo', monospace;
  color: #1d1d1f;
}

.row-name {
  font-size: 13px;
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-type {
  font-size: 12px;
}

.row-layers {
  font-size: 13px;
  color: #86868b;
  text-align: center;
}

.row-modified {
  font-size: 12px;
  color: #86868b;
}

.row-action {
  text-align: right;
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  color: #1d1d1f;
  background: #f0f0f2;
}

.btn:hover {
  background: #e5e5e7;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-view {
  background: #e8f0fe;
  color: #1a73e8;
}

.btn-view:hover {
  background: #d2e3fc;
}

.btn-download {
  background: #1a73e8;
  color: #fff;
}

.btn-download:hover {
  background: #1557b0;
  color: #fff;
}

.btn-secondary {
  background: #f0f0f2;
  color: #1d1d1f;
}

.btn-secondary:hover {
  background: #e5e5e7;
}

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.detail-modal-content {
  background: #fff;
  border-radius: 16px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e5e7;
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: #1d1d1f;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #86868b;
  cursor: pointer;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.modal-close:hover {
  background: #f0f0f2;
  color: #1d1d1f;
}

.detail-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.detail-preview {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-right: 1px solid #e5e5e7;
}

.preview-bg {
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  padding: 24px;
  transition: background .2s;
}

.preview-bg.light {
  background:
    linear-gradient(45deg, #e8e8ea 25%, transparent 25%),
    linear-gradient(-45deg, #e8e8ea 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e8e8ea 75%),
    linear-gradient(-45deg, transparent 75%, #e8e8ea 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-color: #fff;
  border: 1px solid #e5e5e7;
}

.preview-bg.dark {
  background: #1a1a1a;
  border: 1px solid #333;
}

.preview-bg img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.preview-controls {
  display: flex;
  gap: 8px;
}

.detail-info {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table td {
  padding: 6px 0;
  font-size: 13px;
  vertical-align: top;
}

.detail-label {
  color: #86868b;
  font-weight: 500;
  width: 110px;
  padding-right: 12px;
}

.detail-value {
  color: #1d1d1f;
  font-weight: 500;
}

/* ── Color Swatches ───────────────────────────────────── */
.colors-heading {
  font-size: 13px;
  color: #86868b;
  font-weight: 500;
  margin-bottom: 8px;
}

.swatch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.1);
  cursor: default;
  position: relative;
}

.color-swatch.transparent {
  background:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0;
  background-color: #fff;
}

/* ── Download Actions ─────────────────────────────────── */
.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* ── Empty State ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #86868b;
  font-size: 15px;
  grid-column: 1 / -1;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    flex-direction: column;
  }

  .search-input {
    width: 100%;
  }

  .toolbar-right {
    justify-content: space-between;
  }

  .logo-grid.view-gallery {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
  }

  .detail-body {
    grid-template-columns: 1fr;
  }

  .detail-preview {
    border-right: none;
    border-bottom: 1px solid #e5e5e7;
  }

  .logo-row {
    grid-template-columns: 40px 80px 1fr 60px;
  }

  .row-layers,
  .row-modified,
  .row-action {
    display: none;
  }
}
