
.cert-dashboard {
  padding: 24px;
  padding-top: 0;
  background: var(--bg-page);
  min-height: 100%;
  box-sizing: border-box;
  font-family: var(--app-font-family);
}

// ── Header ──────────────────────────────────────────────
.dash-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 10px;
}

.dash-title {
  h2 {
    margin: 0 0 4px;
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
  }
}

.dash-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
}

.btn-add-cert {
  background: var(--button-primary-bg-default);
  color: var(--button-primary-text-default);
  border: 1px solid var(--button-primary-border-default);
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;

  &:hover  { background: var(--button-primary-bg-hover); }
  &:active { background: var(--button-primary-bg-active); }
}

// ── Stat Cards ──────────────────────────────────────────
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 15px;

  @media (max-width: 900px) { grid-template-columns: repeat(2, 1fr); }
  @media (max-width: 500px) { grid-template-columns: 1fr; }
}

.stat-card {
  background: var(--bg-surface);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  mat-icon { font-size: 22px; width: 22px; height: 22px; }

  &.stat-icon-active   { background: var(--category-bg-alpha);  color: var(--category-text-alpha); }
  &.stat-icon-expired  { background: var(--status-error-bg);    color: var(--status-error-text);   }
  &.stat-icon-expiring { background: var(--category-bg-delta);  color: var(--category-text-delta); }
  &.stat-icon-revoked  { background: var(--bg-muted);           color: var(--text-secondary);      }
}

.stat-info {
  .stat-value {
    font-size: 30px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 4px;
  }

  .stat-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.2px;
    color: var(--text-tertiary);
    text-transform: uppercase;
  }
}

// ── Filters ─────────────────────────────────────────────
.dash-filters {
  display: flex;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  flex: 1;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--field-border-default);
  border-radius: 6px;
  font-size: 13px;
  background: var(--field-bg-default);
  color: var(--field-text-default);
  outline: none;

  &::placeholder { color: var(--field-text-placeholder); }
  &:focus { border-color: var(--field-border-focus); }
}

.filter-select {
  padding: 8px 28px 8px 12px;
  border: 1px solid var(--field-border-default);
  border-radius: 6px;
  font-size: 13px;
  background: var(--field-bg-default);
  color: var(--field-text-default);
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;

  &:focus { border-color: var(--field-border-focus); }
}

.records-count {
  font-size: 12px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

// ── Table ────────────────────────────────────────────────
.cert-table-wrap {
  background: var(--bg-surface);
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.table-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(93vh - 340px);
  min-height: 200px;
}

.cert-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;

  thead tr { border-bottom: 1px solid var(--table-border); }

  th {
    padding: 12px 14px;
    text-align: left;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--table-text-header);
    background: var(--table-header-bg);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  tbody tr {
    border-bottom: 1px solid var(--table-border);
    transition: background 0.15s;
    &:last-child { border-bottom: none; }
    &:hover { background: var(--bg-hover); }
  }

  td {
    padding: 10px 14px;
    vertical-align: middle;
    color: var(--table-text-body);
  }
}

.td-certno {
  font-size: 12px;
  font-family: 'Courier New', monospace;
  color: var(--text-secondary);
  white-space: nowrap;
}

.td-employee {
  .emp-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
  }
  .emp-code {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
  }
}

.td-programme {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-secondary);
}

.td-date    { white-space: nowrap; font-size: 12px; color: var(--text-secondary); }
.td-issuedby { font-size: 12px; color: var(--text-secondary); }
.td-days     { text-align: center; }

.days-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;

  &.days-ok      { background: var(--category-bg-alpha);  color: var(--category-text-alpha); }
  &.days-warning { background: var(--category-bg-delta);  color: var(--category-text-delta); }
  &.days-expired { background: var(--status-error-bg);    color: var(--status-error-text);   }
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;

  &.st-active   { background: var(--category-bg-alpha);  color: var(--category-text-alpha); }
  &.st-expired  { background: var(--status-error-bg);    color: var(--status-error-text);   }
  &.st-revoked  { background: var(--bg-muted);           color: var(--text-secondary);      }
  &.st-renewal  { background: var(--category-bg-delta);  color: var(--category-text-delta); }
}

.td-actions {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}

.btn-view,
.btn-edit,
.btn-delete,
.btn-download {
  background: none;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 5px 8px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
  display: flex;
  align-items: center;

  mat-icon { font-size: 16px; width: 16px; height: 16px; }

  &:disabled { opacity: 0.5; cursor: not-allowed; }
}

.btn-view {
  color: var(--text-secondary);
  border-color: var(--border-default);

  &:hover { background: var(--bg-selected); border-color: var(--text-secondary); }
}

.btn-edit {
  color: var(--action-primary-default);
  border-color: var(--action-primary-disabled);

  &:hover { background: var(--bg-selected); border-color: var(--action-primary-default); }
}

.btn-download {
  color: var(--category-text-alpha, #16a34a);
  border-color: var(--category-bg-alpha, #bbf7d0);

  &:hover:not(:disabled) { background: var(--bg-selected); }
}

.signed-doc-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-download-cert,
.btn-verify-cert {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;

  mat-icon { font-size: 16px; width: 16px; height: 16px; }
  &:disabled { opacity: 0.5; cursor: not-allowed; }
}

.btn-download-cert {
  color: var(--category-text-alpha, #16a34a);
  border-color: var(--category-bg-alpha, #bbf7d0);
  &:hover:not(:disabled) { background: var(--bg-selected); }
}

.btn-verify-cert {
  color: var(--action-primary-default);
  border-color: var(--action-primary-disabled);
  &:hover { background: var(--bg-selected); }
}

.btn-delete {
  color: var(--status-error-text);
  border-color: var(--status-error-border);

  &:hover { background: var(--status-error-bg); border-color: var(--status-error-text); }
}

.empty-state {
  text-align: center;
  padding: 48px 0;
  color: var(--text-disabled);
  font-size: 14px;
}

.table-footer {
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text-tertiary);
  border-top: 1px solid var(--table-border);
}

// ── Modal ────────────────────────────────────────────────
.modal {
  display: none;
  position: fixed;
  z-index: 999;
  padding-top: 60px;
  left: 0; top: 0; width: 100%; height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
}

.modal-content-wrapper {
  display: flex;
  justify-content: center;
}

.modal-content {
  background-color: #fefefe;
  margin: auto;
  padding: 0;
  border: 1px solid #888;
  width: 860px;
  min-height: 420px;
  border-radius: 8px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  box-sizing: border-box;
}

.titlecontainer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 21px;
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fefefe;
  border-bottom: 1px solid #e5e5e5;
}

.buttfilter { font-weight: 700; font-size: 18px; margin: 0; color: #333333; }
.icons  { display: flex; gap: 24px; align-items: center; }
.action { display: flex; gap: 16px; align-items: center; }

.save {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 40px; border-radius: 8px; background: #1EAE8A; cursor: pointer; transition: all 0.3s ease;
  mat-icon { color: #fff; font-size: 20px; width: 22px; height: 22px; }
  &:hover { background: #189b7a; transform: translateY(-1px); box-shadow: 0 4px 8px rgba(30,174,138,0.3); }
  &:active { transform: translateY(0); }
}

.delete {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 40px; border-radius: 8px; border: 1px solid #E63946; background: transparent; cursor: pointer; transition: all 0.3s ease;
  mat-icon { color: #E63946; font-size: 20px; width: 20px; height: 20px; }
  &:hover { background: rgba(230,57,70,0.1); transform: translateY(-1px); }
  &:active { transform: translateY(0); }
}

.add {
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 40px; border-radius: 8px; border: 1px solid #818181; background: transparent; cursor: pointer; transition: all 0.3s ease;
  mat-icon { color: #818181; font-size: 20px; width: 20px; height: 20px; }
  &:hover { background: rgba(129,129,129,0.1); border-color: #666; transform: translateY(-1px); }
  &:active { transform: translateY(0); }
}

.closeicon {
  display: flex; align-items: center; justify-content: center; cursor: pointer; transition: transform 0.3s ease;
  mat-icon { width: 27px; height: 27px; font-size: 27px; color: #666666; }
  &:hover { transform: scale(1.1); mat-icon { color: #333333; } }
}

.modal-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 21px 21px;
}

.section-header {
  border-left: 3px solid var(--action-primary-default);
  padding: 6px 10px;
  margin: 14px 0 8px;
  border-bottom: 1px solid var(--border-default);

  span {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.5px;
    color: var(--text-tertiary);
    text-transform: uppercase;
  }
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  margin-bottom: 4px;

  .adjacentField { width: 100%; margin-right: 0; display: block; }
}

[dir="rtl"] {
  .dash-header    { flex-direction: row-reverse; }
  .section-header { border-left: none; border-right: 3px solid var(--action-primary-default); }
}
