/* AUDIT COUNTDOWN - PORTAL DESIGN */

:root {
  --background: #f8f5f0;
  --foreground: #3e2723;
  --primary: #2e7d32;
  --border: #e0d6c9;
  --muted-foreground: #6d4c41;
  --card: #ffffff;
  --secondary: #ffffff;
  --secondary-foreground: #3e2723;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100vh;
  line-height: 1.4;
  font-weight: 400;
  background-color: var(--background);
  color: var(--foreground);
}

.container {
  width: 100%;
  max-width: 1400px;
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: max-content;
  align-content: start;
  gap: 0;
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  padding: 8px 16px 0;
  border-radius: 0;
  flex-wrap: wrap;
  margin: 0;
  background-color: var(--background);
  border-bottom: 0;
  min-height: 0;
}

.filter-btn {
  padding: 12px 18px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border 0.2s, background 0.2s;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  background-color: var(--card);
  color: var(--foreground);
}

.filter-btn img {
  height: 28px;
  width: auto;
  display: block;
}

.filter-btn:hover {
  border-color: var(--primary);
  background-color: #e8f5e9;
}

.filter-btn.active {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.cert-count {
  margin-left: auto;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted-foreground);
  padding: 8px 12px;
  white-space: nowrap;
}

.certificate-list-view {
  width: 100%;
}

/* Certificate Layout */
.cert-layout {
  padding: 14px 16px 20px;
}

.certificate-detail-view {
  width: 100%;
  padding: 14px 16px 20px;
}

.certificate-preview {
  min-height: calc(100vh - 170px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(62, 39, 35, 0.12);
  border-radius: 8px;
  background: var(--card);
  box-shadow: 0 14px 40px rgba(62, 39, 35, 0.08);
}

.detail-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 20px 12px;
}

.preview-label {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.preview-header h1 {
  margin: 0;
  color: var(--foreground);
  font-size: 1.45rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.preview-logos {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  min-width: 48px;
}

.preview-logos img {
  width: auto;
  height: 38px;
  display: block;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 16px;
  color: var(--muted-foreground);
  font-size: 0.86rem;
}

.preview-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(109, 76, 65, 0.14);
  border-radius: 999px;
  background: #fbfaf8;
}

#previewCountdown {
  font-size: 0.78rem;
  font-weight: 700;
  color: #8a3a32;
}

.pdf-viewer-container {
  flex: 1;
  min-height: 620px;
  overflow: hidden;
  border-top: 1px solid var(--border);
  background: #efebe6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pdf-frame {
  width: 100%;
  height: 100%;
  min-height: 620px;
  border: none;
  background: #ffffff;
}

.pdf-frame.hidden {
  display: none;
}

.pdf-no-file {
  max-width: 320px;
  padding: 24px;
  font-size: 0.95rem;
  color: var(--muted-foreground);
  text-align: center;
}

.pdf-btn {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid rgba(62, 39, 35, 0.16);
  border-radius: 8px;
  background-color: var(--card);
  color: var(--foreground);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: border-color 0.2s, background-color 0.2s, transform 0.1s;
}

.pdf-btn:hover {
  border-color: var(--primary);
  background-color: #f1f8f2;
}

.pdf-btn:active {
  transform: scale(0.98);
}

.pdf-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.pdf-action-buttons {
  display: flex;
  gap: 8px;
}

/* Sidebar */
.sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  min-height: 0;
}

@media (min-width: 768px) {
  .sidebar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .sidebar {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Audit Button */
.audit-button {
  width: 100%;
  min-height: 82px;
  padding: 14px 16px;
  margin: 0;
  border: 1px solid rgba(62, 39, 35, 0.12);
  border-radius: 8px;
  text-align: left;
  font-size: 0.8rem;
  font-weight: 400;
  cursor: pointer;
  transition: transform 0.1s, background 0.2s, border-color 0.2s, box-shadow 0.2s;
  box-shadow: 0 6px 18px rgba(62, 39, 35, 0.05);
  display: grid;
  grid-template-columns: minmax(78px, 0.78fr) minmax(90px, 1fr) minmax(46px, auto);
  grid-template-rows: auto auto auto;
  column-gap: 12px;
  row-gap: 5px;
  background-color: var(--card);
  color: var(--foreground);
}

.btn-title-row {
  display: contents;
}

.btn-title {
  font-weight: 700;
  font-size: 1rem;
  text-align: left;
  grid-column: 2;
  grid-row: 1 / 3;
  align-self: center;
  line-height: 1.18;
}

.btn-logos {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
  grid-column: 3;
  grid-row: 1 / 3;
}

.btn-date-val {
  grid-column: 1;
  grid-row: 1;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  color: var(--muted-foreground);
  line-height: 1.2;
}

.btn-time-val {
  grid-column: 1;
  grid-row: 2;
  font-size: 0.76rem;
  font-weight: 400;
  text-align: left;
  color: var(--muted-foreground);
  line-height: 1.2;
}

.btn-countdown {
  grid-column: 1 / -1;
  grid-row: 3;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0;
  color: #8a3a32;
  opacity: 0.82;
}

.logo-icon {
  height: 34px;
  width: auto;
  display: inline-block;
}

.audit-button:hover {
  transform: translateY(-1px);
  border-color: var(--primary);
  background-color: #fbfaf8;
  box-shadow: 0 10px 26px rgba(62, 39, 35, 0.09);
}

.audit-button:active {
  transform: scale(0.98);
}

/* Responsive */
@media (max-width: 768px) {
  .cert-layout {
    padding: 12px;
  }

  .certificate-detail-view {
    padding: 10px 8px 16px;
  }

  .certificate-preview {
    min-height: calc(100vh - 210px);
  }

  .detail-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .pdf-action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .preview-header {
    padding: 16px 16px 10px;
  }

  .preview-header h1 {
    font-size: 1.25rem;
  }

  .preview-meta {
    padding: 0 16px 14px;
  }

  .pdf-viewer-container,
  .pdf-frame {
    min-height: calc(100vh - 300px);
  }

  .filter-bar {
    padding: 8px 12px 0;
    gap: 8px;
  }

  .filter-btn {
    padding: 10px 14px;
    height: 48px;
  }

  .filter-btn img {
    height: 24px;
  }

  .sidebar {
    gap: 10px;
  }

  .audit-button {
    padding: 10px 12px;
  }
}

@media (max-width: 480px) {
  .cert-layout {
    padding: 10px;
  }

  .certificate-detail-view {
    padding: 8px 6px 14px;
  }

  .certificate-preview {
    min-height: calc(100vh - 205px);
  }

  .preview-header {
    align-items: flex-start;
  }

  .preview-logos img {
    height: 30px;
  }

  .pdf-viewer-container,
  .pdf-frame {
    min-height: calc(100vh - 295px);
  }

  .filter-bar {
    padding: 8px 10px 0;
    gap: 8px;
  }

  .filter-btn {
    padding: 8px 12px;
    height: 44px;
    font-size: 12px;
  }

  .filter-btn img {
    height: 20px;
  }

  .sidebar {
    gap: 8px;
  }

  .audit-button {
    min-height: 78px;
    padding: 10px 12px;
    font-size: 0.75rem;
  }
}
