/* ==========================================
   PUBLIC SIGN FORM — Styles
   ========================================== */

:root {
  --brand-primary: #2c3e50;
  --brand-primary-light: #34495e;
  --brand-dark: #2c3e50;
  --brand-bg: #f7f9fc;
  --card-shadow: 0 2px 8px rgba(0,0,0,.06);
  --card-shadow-hover: 0 4px 16px rgba(0,0,0,.10);
}

/* --- Global --- */
body.sign-page {
  background: var(--brand-bg);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--brand-dark);
}

/* --- Portal Header --- */
.portal-header {
  background: #fff;
  border-bottom: 1px solid #e0e4e8;
  margin-bottom: 2rem;
}
.portal-logo {
  padding: 1rem 0 .75rem;
}
.portal-logo img {
  max-height: 48px;
}
.portal-nav {
  border-top: 1px solid #eef0f3;
}
.portal-nav-links {
  display: flex;
  justify-content: center;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.portal-nav-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .75rem 1.25rem;
  font-size: .9rem;
  font-weight: 500;
  color: #6c757d;
  text-decoration: none;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color .2s, border-color .2s;
}
.portal-nav-link:hover {
  color: var(--brand-primary);
}
.portal-nav-link.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}
.portal-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--brand-primary);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  line-height: 1;
}

/* --- Portal Tab Content --- */
.portal-section-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}

/* --- Sign Types Grid --- */
.sign-types-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.25rem;
}
.sign-type-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff;
  border-radius: .75rem;
  padding: 1.25rem 1rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #eef0f3;
  text-decoration: none;
  color: var(--brand-dark);
  transition: box-shadow .2s, transform .15s;
}
.sign-type-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
  color: var(--brand-dark);
}
.sign-type-img {
  width: 100%;
  max-height: 140px;
  object-fit: contain;
  border-radius: .5rem;
  margin-bottom: .75rem;
  background: #f8f9fa;
}
.sign-type-img-placeholder {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f3f5;
  border-radius: .5rem;
  margin-bottom: .75rem;
  color: #ced4da;
  font-size: 2.5rem;
}
.sign-type-name {
  font-weight: 600;
  font-size: .95rem;
  margin-bottom: .5rem;
}

/* Portal action button (replaces red btn-new-sign) */
.btn-portal-action {
  background: var(--brand-primary);
  color: #fff;
  border: none;
  border-radius: .4rem;
  font-weight: 600;
  padding: .4rem 1rem;
  font-size: .85rem;
  transition: all .2s;
}
.btn-portal-action:hover {
  background: var(--brand-primary-light);
  color: #fff;
  transform: translateY(-1px);
}

/* Portal table */
.portal-table thead th {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: #6c757d;
  border-bottom: 2px solid #e0e4e8;
}
.portal-table td {
  vertical-align: middle;
}

/* --- Progress bar --- */
.progress-wrapper {
  background: #fff;
  border-radius: .75rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}
.progress-wrapper .progress {
  height: 8px;
  border-radius: 4px;
  background: #e9ecef;
}
.progress-wrapper .progress-bar {
  background: linear-gradient(90deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
  border-radius: 4px;
  transition: width .4s ease;
}
.progress-wrapper .progress-text {
  font-size: .8rem;
  color: #6c757d;
  margin-top: .4rem;
}

/* --- Form card wrapper --- */
.form-section {
  background: #fff;
  border-radius: .75rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #eef0f3;
}

/* --- Single element fields --- */
.field-group {
  margin-bottom: 1rem;
}
.field-group:last-child {
  margin-bottom: 0;
}
.field-group label {
  font-weight: 600;
  font-size: .85rem;
  color: var(--brand-dark);
  margin-bottom: .3rem;
}
.field-group .form-control {
  border-radius: .5rem;
  border: 1.5px solid #dee2e6;
  padding: .6rem .85rem;
  font-size: .95rem;
  transition: border-color .2s, box-shadow .2s;
}
.field-group .form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(44,62,80,.1);
}

/* --- Repeated row (group) --- */
.sign-row {
  background: #fff;
  border-radius: .75rem;
  margin-bottom: 1rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #eef0f3;
  overflow: hidden;
  transition: box-shadow .2s;
}
.sign-row:hover {
  box-shadow: var(--card-shadow-hover);
}
.sign-row-header {
  background: linear-gradient(135deg, #f8f9fa, #eef0f3);
  padding: .6rem 1.25rem;
  font-weight: 700;
  font-size: .85rem;
  color: var(--brand-dark);
  border-bottom: 1px solid #eef0f3;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sign-row-header .row-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}
.sign-row-body {
  padding: 1rem 1.25rem;
}
.sign-row-body .field-group label {
  font-size: .8rem;
}
.sign-row-body .form-control {
  font-size: .9rem;
  padding: .5rem .75rem;
}

/* Fields grid inside rows */
.fields-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .75rem 1rem;
}

/* --- Icon slots --- */
.icon-slot {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border: 2px dashed #d1d5db;
  border-radius: .5rem;
  cursor: pointer;
  min-height: 48px;
  transition: all .2s;
  background: #fafbfc;
}
.icon-slot:hover {
  border-color: var(--brand-primary);
  background: #fff;
}
.icon-slot[data-selected] {
  border-style: solid;
  border-color: #198754;
  background: #f0fdf4;
}
.icon-slot-sm {
  padding: .35rem .5rem;
  min-height: 42px;
}
.icon-placeholder {
  color: #9ca3af;
  font-size: .85rem;
}
.icon-selected-label {
  font-size: .85rem;
  font-weight: 500;
  color: var(--brand-dark);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fee2e2;
  color: #dc2626;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.icon-clear:hover {
  background: #dc2626;
  color: #fff;
}

/* --- Preview panel --- */
.preview-panel {
  background: #fff;
  border-radius: .75rem;
  padding: 1.5rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #eef0f3;
}
.preview-panel h5 {
  font-size: .9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #6c757d;
  margin-bottom: 1rem;
}
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  background: #f8f9fa;
  border-radius: .5rem;
  border: 2px dashed #dee2e6;
  color: #9ca3af;
  text-align: center;
  padding: 2rem;
}
.preview-placeholder i {
  font-size: 3rem;
  margin-bottom: .75rem;
  opacity: .4;
}
.preview-placeholder p {
  margin: 0;
  font-size: .9rem;
}
#previewArea img {
  max-height: 70vh;
  border-radius: .5rem;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  cursor: zoom-in;
  transition: opacity .15s;
}
#previewArea img:hover {
  opacity: .9;
}
.preview-hint {
  font-size: .75rem;
  color: #9ca3af;
  margin-top: .35rem;
}

/* --- Lightbox --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  animation: lbFadeIn .2s ease;
  padding: 1.5rem;
}
@keyframes lbFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.lightbox-overlay img {
  max-width: 95vw;
  max-height: 95vh;
  object-fit: contain;
  border-radius: .5rem;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
  background: #fff;
  padding: .5rem;
}

/* Action buttons */
.btn-generate {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
  color: #fff;
  border: none;
  border-radius: .5rem;
  font-weight: 600;
  font-size: 1rem;
  padding: .75rem 1.5rem;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(44,62,80,.25);
}
.btn-generate:hover {
  background: linear-gradient(135deg, #1a252f 0%, var(--brand-primary) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(44,62,80,.35);
  transform: translateY(-1px);
}
.btn-generate:disabled {
  opacity: .65;
  transform: none;
}
.btn-confirm {
  background: linear-gradient(135deg, #27ae60 0%, #2ecc71 100%);
  color: #fff;
  border: none;
  border-radius: .5rem;
  font-weight: 600;
  font-size: 1rem;
  padding: .75rem 1.5rem;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(39,174,96,.25);
}
.btn-confirm:hover {
  background: linear-gradient(135deg, #219a52 0%, #27ae60 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(39,174,96,.35);
  transform: translateY(-1px);
}

/* Save status */
#saveStatus {
  font-size: .8rem;
}

/* --- Drafts page --- */
.drafts-header {
  text-align: center;
  margin-bottom: 2rem;
}
.drafts-header h2 {
  font-weight: 700;
  color: var(--brand-dark);
}
.drafts-header p {
  color: #6c757d;
  font-size: .95rem;
}
.draft-card {
  background: #fff;
  border-radius: .75rem;
  box-shadow: var(--card-shadow);
  border: 1px solid #eef0f3;
  transition: box-shadow .2s, transform .15s;
  overflow: hidden;
}
.draft-card:hover {
  box-shadow: var(--card-shadow-hover);
  transform: translateY(-2px);
}
.draft-card .draft-preview {
  width: 120px;
  min-height: 80px;
  object-fit: contain;
  background: #f8f9fa;
  flex-shrink: 0;
}
.draft-card .draft-preview-empty {
  width: 120px;
  min-height: 80px;
  background: #f1f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ced4da;
  font-size: 2rem;
  flex-shrink: 0;
}
.btn-new-sign {
  background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-light) 100%);
  color: #fff;
  border: none;
  border-radius: .5rem;
  font-weight: 600;
  padding: .65rem 1.5rem;
  box-shadow: 0 2px 8px rgba(44,62,80,.25);
  transition: all .2s;
}
.btn-new-sign:hover {
  color: #fff;
  box-shadow: 0 4px 12px rgba(44,62,80,.35);
  transform: translateY(-1px);
}

/* --- Icon picker enhancements --- */
.icon-option:hover {
  background-color: #eef2f7;
}

/* --- Responsive --- */
@media (max-width: 991px) {
  .portal-logo { padding: .75rem 0 .5rem; }
  .portal-logo img { max-height: 36px; }
  .portal-nav-link { padding: .6rem .75rem; font-size: .82rem; }
  .form-section, .sign-row-body { padding: 1rem; }
  .fields-grid { grid-template-columns: 1fr; }
  .preview-panel { margin-top: 1.5rem; }
  .sign-types-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1rem; }
}

@media (max-width: 575px) {
  .portal-nav-links { gap: 0; }
  .portal-nav-link { padding: .6rem .6rem; font-size: .78rem; }
  .draft-card .draft-preview,
  .draft-card .draft-preview-empty { width: 80px; min-height: 60px; }
}
