/* =========================
   Global base
   ========================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background-color: #f4f4f4;
  font-family: Arial, sans-serif;
  padding: 20px;
}

h1, h2, h3 {
  color: #004477;
}

a {
  color: #0077cc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid rgba(13, 110, 253, 0.6);
  outline-offset: 2px;
}

/* =========================
   Public page containers
   ========================= */
.public-dpp-container {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

/* Full-bleed support for the Public DPP page */
.public-dpp .public-dpp-main {
  padding: 0;
  margin: 0;
  max-width: none;
  width: 100%;
}

.public-dpp {
  /* overrides global body defaults for the DPP page */
  background-color: #0b0f17;
  padding: 0;
}

/* =========================
   Tables (Products + generic)
   ========================= */
.product-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1em;
}

.product-table th,
.product-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #e0e0e0;
}

.product-table th {
  background-color: #f4f4f4;
  text-align: left;
  border: 1px solid #ddd;
}

.product-table td {
  border: 1px solid #ddd;
}

.product-table tr:hover {
  background-color: #fafafa;
}

/* Keep table readable on small screens */
@media (max-width: 640px) {
  .product-table th,
  .product-table td {
    padding: 8px;
  }
}

/* Generic .table (Bootstrap-like) */
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.table th, .table td {
  padding: 6px 10px;
  border: 1px solid #ddd;
}

.table th {
  background-color: #f8f9fa;
  font-weight: 600;
}

.table-striped tbody tr:nth-of-type(odd) {
  background-color: #f9f9f9;
}

/* =========================
   Sorting styles
   ========================= */
th button.sort,
.sort {
  background: none;
  border: none;
  color: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease;
}

th button.sort:hover,
.sort:hover {
  color: #007bff;
}

th button.sort:after {
  content: '⇅';
  font-size: 0.8em;
  margin-left: 4px;
  color: #aaa;
  transition: color 0.2s ease, transform 0.2s ease;
}

th button.sort.asc:after {
  content: '▲';
  color: #333;
  transform: translateY(-1px);
}

th button.sort.desc:after {
  content: '▼';
  color: #333;
  transform: translateY(1px);
}

.sort:focus {
  outline: none;
}

.product-table thead th:hover {
  background-color: #f8f9fa;
}

/* =========================
   Buttons + utility
   ========================= */
.button-clear {
  display: inline-block;
  padding: 6px 12px;
  background-color: #f5f5f5;
  border: 1px solid #000000;
  color: #333333;
  text-decoration: none;
  border-radius: 4px;
}

.button-clear:hover {
  background-color: #e0e0e0;
}

.copy-url-btn {
  background-color: #eef;
  border: 1px solid #99c;
  padding: 4px 8px;
  font-size: 13px;
  border-radius: 4px;
  cursor: pointer;
}

.copy-url-btn:hover {
  background-color: #dde;
}

.text-muted {
  font-style: italic;
}

.btn-outline-primary {
  margin-top: 10px;
}

/* =========================
   Toast
   ========================= */
#toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background-color: #333;
  color: #fff;
  padding: 10px 20px;
  border-radius: 6px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease-in-out;
  z-index: 9999;
  font-size: 14px;
}

#toast.toast-visible {
  opacity: 1;
}

/* =========================
   Profile menu
   ========================= */
.profile-icon-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #0d6efd;
}

.profile-icon-btn:hover {
  color: #0a58ca;
}

.profile-menu {
  display: none;
  position: absolute;
  top: 30px;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  width: 180px;
  z-index: 999;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.profile-menu a,
.profile-header {
  display: block;
  padding: 10px 15px;
  text-decoration: none;
  color: #333;
}

.profile-menu a:hover {
  background-color: #f0f0f0;
}

.profile-header {
  font-weight: bold;
  background-color: #f9f9f9;
}

/* =========================
   Search + filters
   ========================= */
#product-list .search {
  width: 100%;
  max-width: 350px;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

/* Search bar with clear button */
.search-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 350px;
}

.search-wrapper .search {
  width: 100%;
  padding-right: 28px; /* space for clear button */
}

.search-wrapper .clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: none;
  font-size: 1.2em;
  color: #999;
  cursor: pointer;
  line-height: 1;
  padding: 0;
}

.search-wrapper .clear-search:hover {
  color: #333;
}

.clear-search {
  display: none;
  padding: 0 8px;
}

.filter-form select,
.filter-form input[type="date"] {
  padding: 4px 8px;
  margin-right: 4px;
}

.filter-form button,
.filter-form a.btn {
  margin-left: 6px;
}


/* =========================
   Public DPP (certificate UI)
   ========================= */

  /* Page base */
  .dpp-page{
    position: relative;
    min-height: 100vh;
    overflow: hidden;
    background: radial-gradient(1200px 800px at 20% 10%, rgba(64,120,255,0.10), transparent 60%),
                radial-gradient(900px 600px at 80% 30%, rgba(0,255,200,0.06), transparent 55%),
                #0b0f17;
    color: #e9eefc;
  }

  /* Background canvas */
  #dpp-bg-canvas{
    position:absolute;
    inset:0;
    width:100%;
    height:100%;
    opacity: 0.40; /* subtle */
    pointer-events:none;
  }

  /* Center shell */
  .dpp-shell{
    position: relative;
    z-index: 1;
    display:flex;
    justify-content:center;
    padding: 28px 14px 48px;
  }

  /* Certificate card */
  .dpp-card{
    width: min(720px, 100%);
    background: rgba(13, 18, 30, 0.78);
    border: 1px solid rgba(255,255,255,0.10);
    box-shadow: 0 18px 60px rgba(0,0,0,0.55);
    border-radius: 22px;
    backdrop-filter: blur(10px);
    padding: 22px 18px;
  }

  .dpp-header{ margin-bottom: 14px; }

  .dpp-kicker{
    font-size: 12px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(233,238,252,0.72);
    margin-bottom: 10px;
  }

  .dpp-title{
    font-size: 26px;
    line-height: 1.15;
    margin: 0 0 12px 0;
  }

  .dpp-badges{
    display:flex;
    gap: 8px;
    flex-wrap: wrap;
  }

  .dpp-badge{
    font-size: 12px;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(64,120,255,0.35);
    background: rgba(64,120,255,0.12);
    color: rgba(233,238,252,0.95);
  }
  .dpp-badge-muted{
    border-color: rgba(255,255,255,0.18);
    background: rgba(255,255,255,0.06);
    color: rgba(233,238,252,0.82);
  }

  .dpp-description{
    margin: 14px 0 18px;
    color: rgba(233,238,252,0.86);
    line-height: 1.5;
  }

  .dpp-grid{
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 4px;
  }

  .dpp-field{
    border: 1px solid rgba(255,255,255,0.09);
    background: rgba(255,255,255,0.04);
    border-radius: 14px;
    padding: 12px 12px;
  }

  .dpp-field-wide{ grid-column: 1 / -1; }

  .dpp-label{
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(233,238,252,0.62);
    margin-bottom: 6px;
  }

  .dpp-value{
    font-size: 15px;
    color: #ffffff;
    word-break: break-word;
  }

  .mono{
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 14px;
    color: rgba(233,238,252,0.92);
  }

  .dpp-link{
    color: rgba(160,200,255,0.95);
    text-decoration: none;
    border-bottom: 1px dashed rgba(160,200,255,0.45);
    word-break: break-all;
  }
  .dpp-link:hover{ border-bottom-style: solid; }

  .dpp-notes{
    margin-top: 14px;
    border: 1px solid rgba(255,255,255,0.09);
    background: rgba(255,255,255,0.03);
    border-radius: 14px;
    padding: 12px 12px;
  }
  .dpp-notes-body{
    color: rgba(233,238,252,0.88);
    line-height: 1.5;
    white-space: pre-wrap;
  }

  .dpp-footer{
    display:flex;
    justify-content: flex-start;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255,255,255,0.08);
    flex-wrap: wrap;
  }

  .dpp-footer-label{
    font-size: 11px;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(233,238,252,0.55);
    margin-bottom: 4px;
  }

  .dpp-footer-brand{
    font-size: 14px;
    color: #f37321	;
    font-weight: 700;
  }

  .dpp-footer-tip{
    font-size: 13px;
    color: rgba(233,238,252,0.78);
  }

  /* Larger screens */
  @media (min-width: 640px){
    .dpp-card{ padding: 28px 26px; }
    .dpp-title{ font-size: 30px; }
    .dpp-grid{ grid-template-columns: 1fr 1fr; }
  }

  .dpp-footer-brand-link {
  font-size: 14px;
  font-weight: 700;
  color: #f37321;
  text-decoration: none;
}

.dpp-footer-brand-link,
.dpp-footer-brand-link:link,
.dpp-footer-brand-link:visited,
.dpp-footer-brand-link:hover,
.dpp-footer-brand-link:focus,
.dpp-footer-brand-link:active {
  color: #f37321 !important;
  text-decoration: none !important;
}

a {
  -webkit-tap-highlight-color: transparent;
}

.dpp-value a {
  color: #ffffff;
  border-bottom: 1px solid rgba(255,255,255,0.3);
  text-decoration: none;
}

.dpp-value a:hover {
  color: #f37321;
  border-bottom: 1px solid #f37321;
}

.custom-field-value a {
  color: #ffffff;
  text-decoration: none;
  word-break: break-word;
}

.custom-field-value a:hover {
  color: #f37321;
  text-decoration: underline;
}


.section-title {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 10px;
}

.section-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 24px 0 16px;
}

/* LIGHT MODE */

.public-dpp.light .dpp-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(10, 20, 40, 0.08);
  box-shadow: 0 20px 60px rgba(10, 20, 40, 0.08);
}

.public-dpp.light .dpp-kicker,
.public-dpp.light .dpp-label,
.public-dpp.light .section-title,
.public-dpp.light .dpp-footer-label {
  color: rgba(20, 30, 50, 0.55);
}

.public-dpp.light .dpp-title,
.public-dpp.light .dpp-description,
.public-dpp.light .dpp-value,
.public-dpp.light .dpp-notes-body,
.public-dpp.light .dpp-footer-brand-link {
  color: #1f2937;
}

.public-dpp.light .dpp-field {
  background: #e4e4e4;
    /*background: #f7f9fc;*/
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.public-dpp.light .dpp-badge {
  background: rgba(34, 64, 130, 0.08);
  color: #224082;
  border: 1px solid rgba(34, 64, 130, 0.18);
}

.public-dpp.light .dpp-badge-muted {
  background: rgba(15, 23, 42, 0.04);
  color: #374151;
  border: 1px solid rgba(15, 23, 42, 0.10);
}

.public-dpp.light .dpp-link,
.public-dpp.light .dpp-value a,
.public-dpp.light .custom-field-value a,
.public-dpp.light .dpp-footer-brand-link {
  color: #224082;
}

.public-dpp.light .dpp-link:hover,
.public-dpp.light .dpp-value a:hover,
.public-dpp.light .custom-field-value a:hover,
.public-dpp.light .dpp-footer-brand-link:hover {
  color: #f37321;
}

.public-dpp.light .section-divider {
  background: rgba(15, 23, 42, 0.08);
}

.public-dpp.light #dpp-bg-canvas {
  display: none;
}

.public-dpp.light .dpp-page {
  background: #e4e4e4;
}

.public-dpp.light .dpp-shell {
  position: relative;
  z-index: 1;
}

.dpp-product-image {
    max-width: 600px;
    margin: 18px auto 22px;
    padding: 10px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.10);
    overflow: hidden;
}

.dpp-product-image img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 450px;
    object-fit: contain;
    border-radius: 12px;
}

/* Light mode */
.public-dpp.light .dpp-product-image {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

/* Dark mode */
.public-dpp.dark .dpp-product-image {
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
}

/* Mobile tuning */
@media (max-width: 768px) {
    .dpp-product-image {
        margin: 16px 0 20px;
        padding: 8px;
        border-radius: 16px;
    }

    .dpp-product-image img {
        max-height: 340px;
        border-radius: 10px;
    }
}

@media (hover: hover) {
    .dpp-product-image img {
        transition: transform 0.25s ease;
    }

    .dpp-product-image:hover img {
        transform: scale(1.01);
    }
}

.dashboard-actions-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Writer status */
.writer-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}

.writer-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

/* Connected (green) */
.writer-connected {
  background: #eef7ee;
  color: #1f6b2a;
  border-color: #cfe7d2;
}

.writer-connected .writer-status-dot {
  background: #2ea043;
}

/* Disconnected (grey) */
.writer-disconnected {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #d9dde3;
}

.writer-disconnected .writer-status-dot {
  background: #9ca3af;
} 

.table-actions .action-link {
  color: #1f3c88;
  text-decoration: none;
  font-weight: 400;
}

.table-actions .action-link:hover {
  text-decoration: underline;
}

.table-actions .action-link-write {
  color: #f37321 !important;
  font-weight: 600;
}

.table-actions .action-link-copy-priority {
  color: #f37321 !important;
  font-weight: 600;
}

.table-actions .action-link-disabled {
  color: #aeb4bf !important;
  pointer-events: none;
  cursor: not-allowed;
  text-decoration: none;
  font-weight: 400;
}

.table-actions .action-link-delete {
  color: #6b7280;
  font-weight: 400;
}

.write-tag-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.write-tag-modal {
  width: 100%;
  max-width: 560px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.write-tag-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #e5e7eb;
}

.write-tag-modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #0f172a;
}

.write-tag-modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
}

.write-tag-modal-body {
  padding: 22px;
}

.write-tag-modal-text {
  margin: 0 0 14px 0;
  color: #334155;
}

.write-tag-url-preview {
  background: #f8fafc;
  border: 1px solid #dbe3ec;
  border-radius: 12px;
  padding: 14px;
  font-size: 0.95rem;
  color: #0f172a;
  word-break: break-word;
  margin-bottom: 18px;
}

.write-tag-lock-section {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  padding: 14px;
}

.write-tag-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: #b91c1c;
  margin-bottom: 10px;
}

.write-tag-warning {
  font-size: 0.92rem;
  color: #9a3412;
  line-height: 1.4;
}

.write-tag-status-message {
  margin-top: 16px;
  font-size: 0.95rem;
  color: #334155;
  min-height: 20px;
}

.write-tag-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 22px;
  border-top: 1px solid #e5e7eb;
}

.write-tag-cancel-btn,
.write-tag-confirm-btn {
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
}

.write-tag-cancel-btn {
  background: #e5e7eb;
  color: #1f2937;
}

.write-tag-confirm-btn {
  background: #f37321;
  color: #ffffff;
}

.write-tag-confirm-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.write-tag-feedback {
  margin-top: 16px;
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.write-tag-feedback-idle {
  background: #f8fafc;
  border: 1px solid #dbe3ec;
}

.write-tag-feedback-loading {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.write-tag-feedback-success {
  background: #eefbf3;
  border: 1px solid #b7ebc6;
  color: #166534;
}

.write-tag-feedback-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}

.write-tag-status-message {
  font-size: 0.95rem;
  line-height: 1.4;
}

.write-tag-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid #cbd5e1;
  border-top-color: #f37321;
  border-radius: 50%;
  animation: writeTagSpin 0.8s linear infinite;
  flex: 0 0 18px;
}

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

.write-tag-warning,
.overwrite-warning-box {
  margin-top: 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.4;
}