* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:host {
  display: block;
  height: 100vh;
  overflow: hidden;
  font-family: var(--app-font-family);
  background: #f5f5fa;
  color: var(--text-primary, #1d2939);
  font-size: 13px;
}

.learner-portal {
  height: 100%;
  display: flex;
  flex-direction: column;
}

mat-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ===================================
   HEADER
=================================== */

.topbar {
  flex-shrink: 0;
  z-index: 20;

  background: linear-gradient(90deg, var(--button-primary-bg-default, #834dd0) 0%, var(--button-primary-bg-active, #6f3eb4) 100%);
  color: var(--button-primary-text-default, #fff);

  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 10px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;

    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;

    .logo-icon {
      display: flex;
      align-items: center;
      justify-content: center;

      width: 34px;
      height: 34px;
      border-radius: 9px;

      background: rgba(255, 255, 255, 0.18);

      mat-icon {
        font-size: 19px;
        width: 19px;
        height: 19px;
      }
    }
  }

  .nav-menu {
    display: flex;
    gap: 4px;

    background: rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 4px;

    overflow-x: auto;
    scrollbar-width: none;

    &::-webkit-scrollbar {
      display: none;
    }

    a {
      padding: 8px 16px;
      border-radius: 7px;
      cursor: pointer;
      white-space: nowrap;

      font-size: 13px;
      font-weight: 500;
      color: rgba(255, 255, 255, 0.85);

      transition: background 0.15s ease, color 0.15s ease;

      &:hover {
        color: #fff;
      }

      &.active {
        background: #fff;
        color: var(--button-primary-bg-default, #834dd0);
        font-weight: 600;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
      }
    }
  }

  .profile {
    display: flex;
    align-items: center;
    gap: 10px;

    padding-left: 14px;
    border-left: 1px solid rgba(255, 255, 255, 0.25);

    .user-info {
      text-align: right;
      white-space: nowrap;

      h4 {
        font-size: 13px;
        font-weight: 600;
        line-height: 1.3;
      }

      span {
        font-size: 11px;
        opacity: 0.85;
      }
    }

    .avatar {
      flex-shrink: 0;

      width: 34px;
      height: 34px;
      border-radius: 50%;

      background: rgba(255, 255, 255, 0.15);
      border: 1.5px solid rgba(255, 255, 255, 0.5);

      display: flex;
      align-items: center;
      justify-content: center;

      font-size: 12px;
      font-weight: 700;
    }
  }
}

/* ===================================
   CONTENT
=================================== */

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  padding: 24px;
  max-width: 1440px;
  width: 100%;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;

  margin-bottom: 22px;

  h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary, #1d2939);
  }

  p {
    font-size: 12px;
    color: var(--text-tertiary, #667085);

    strong {
      color: var(--text-link, var(--button-primary-bg-default));
    }
  }
}

.badge-outline {
  display: inline-flex;
  align-items: center;
  gap: 6px;

  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-default, #d0d5dd);
  background: var(--bg-surface, #fff);

  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #344054);
  white-space: nowrap;

  mat-icon {
    font-size: 16px;
    width: 16px;
    height: 16px;
  }
}

.stat-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;

  .stat-pill-btn {
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-default, #d0d5dd);
    background: var(--bg-surface, #fff);

    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    text-transform: uppercase;
    color: var(--text-tertiary, #667085);
    white-space: nowrap;
  }
}

/* ===================================
   DASHBOARD — HIGHLIGHT CARDS
=================================== */

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;

  margin-bottom: 24px;
}

.highlight-card {
  background: var(--bg-surface, #fff);
  border-radius: 14px;
  border-top: 3px solid var(--border-default, #d0d5dd);

  padding: 20px;

  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.15s ease, transform 0.15s ease;

  &:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
  }

  .tag {
    display: flex;
    align-items: center;
    gap: 6px;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: .3px;
    text-transform: uppercase;
    margin-bottom: 12px;

    .dot {
      width: 6px;
      height: 6px;
      border-radius: 50%;
      background: currentColor;
    }
  }

  h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary, #1d2939);
  }

  .subtitle {
    color: var(--text-tertiary, #98a2b3);
    font-size: 11px;
    margin-bottom: 14px;
  }

  &.in-progress {
    border-top-color: var(--border-error, #ef4444);
    width: 800px;

    .tag {
      color: var(--status-error-text, #ef4444);
    }
  }

  &.upcoming {
    border-top-color: var(--category-text-alpha, #2f6fed);

    .tag {
      color: var(--category-text-alpha, #2f6fed);
    }
  }

  &.feedback {
    border-top-color: var(--border-success, #10b981);

    .tag {
      color: var(--status-success-text, #10b981);
    }
  }
}

.progress-bar {
  width: 100%;
  height: 6px;

  background: var(--bg-muted, #e4e7ec);
  border-radius: 20px;
  overflow: hidden;

  margin-bottom: 8px;

  .fill {
    height: 100%;

    &.red {
      background: linear-gradient(90deg, var(--button-primary-bg-default, #834dd0), #14b8a6);
    }
  }
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;

  font-size: 11px;
  color: var(--text-tertiary, #667085);

  margin-bottom: 14px;
}

.upcoming-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;

  font-size: 11px;
  color: var(--text-tertiary, #667085);

  margin-bottom: 14px;
}

.feedback-banner {
  background: var(--status-warning-bg, #fffbeb);
  color: var(--status-warning-error, #b45309);

  border-radius: 6px;
  padding: 8px 10px;

  font-size: 11px;
  font-weight: 600;

  margin-bottom: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  padding: 3px 10px;
  border-radius: 16px;

  font-size: 11px;
  font-weight: 600;

  mat-icon {
    font-size: 13px;
    width: 13px;
    height: 13px;
  }

  &.enrolled {
    background: var(--bg-selected, #f4effe);
    color: var(--text-link, #834dd0);
  }

  &.active {
    background: var(--badge-success, #d1fae5);
    color: var(--status-success-text, #047857);
  }

  &.expired {
    background: var(--badge-error, #fee2e2);
    color: var(--status-error-text, #b91c1c);
  }

  &.done {
    background: var(--badge-success, #d1fae5);
    color: var(--status-success-text, #047857);
  }

  &.notdone {
    background: var(--bg-subtle, #f4f5f7);
    color: var(--text-tertiary, #7b8794);
  }
}

/* ===================================
   DASHBOARD — BOTTOM PANELS
=================================== */

.dashboard-bottom {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
}

.panel {
  background: var(--bg-surface, #fff);
  border-radius: 14px;
  padding: 20px;

  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);

  h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary, #1d2939);
  }
}

.panel-subtitle {
  font-size: 11px;
  color: var(--text-tertiary, #98a2b3);
  margin-top: 2px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;

  margin-bottom: 14px;
}

.link-btn {
  flex-shrink: 0;

  background: none;
  border: 1px solid var(--border-default, #d0d5dd);
  border-radius: 8px;
  padding: 6px 14px;
  cursor: pointer;

  font-size: 12px;
  font-weight: 600;
  color: var(--text-link, var(--button-primary-bg-default));

  &:hover {
    background: var(--bg-selected, #f4effe);
  }
}

.cert-row {
  display: flex;
  align-items: center;
  gap: 12px;

  padding: 12px 8px;
  margin: 0 -8px;
  border-radius: 8px;
  border-bottom: 1px solid var(--border-subtle, #edf1f5);

  transition: background 0.15s ease;

  &:hover {
    background: var(--bg-hover, #f9fafb);
  }

  &:last-of-type {
    border-bottom: none;
  }

  .cert-icon {
    flex-shrink: 0;

    width: 40px;
    height: 40px;
    border-radius: 10px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: linear-gradient(135deg, var(--button-primary-bg-default, #834dd0), var(--button-primary-bg-active, #6f3eb4));
    color: #fff;

    mat-icon {
      font-size: 19px;
      width: 19px;
      height: 19px;
    }
  }

  .cert-info {
    flex: 1;
    min-width: 0;

    h4 {
      font-size: 13px;
      font-weight: 600;
      margin-bottom: 2px;
      color: var(--text-primary, #1d2939);
    }

    span {
      font-size: 11px;
      color: var(--text-tertiary, #98a2b3);
    }
  }

  .cert-status {
    text-align: right;
    flex-shrink: 0;

    .valid-until {
      display: block;
      font-size: 11px;
      color: var(--text-tertiary, #98a2b3);
      margin-top: 4px;
    }
  }
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;

  margin-bottom: 16px;
}

.summary-tile {
  background: var(--bg-subtle, #fafafa);
  border: 1px solid var(--border-subtle, #edf1f5);
  border-radius: 10px;

  padding: 14px 16px;

  .tile-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 6px;
  }

  h2 {
    font-size: 26px;
    font-weight: 700;
    line-height: 1;

    &.green {
      color: var(--status-success-text, #12b76a);
    }

    &.orange {
      color: var(--status-warning-error, #d97706);
    }

    &.blue {
      color: var(--category-text-alpha, #2563eb);
    }

    &.purple {
      color: var(--button-primary-bg-default, #7c3aed);
    }
  }

  .tile-icon {
    flex-shrink: 0;

    width: 32px;
    height: 32px;
    border-radius: 8px;

    display: flex;
    align-items: center;
    justify-content: center;

    mat-icon {
      font-size: 16px;
      width: 16px;
      height: 16px;
    }

    &.icon-green {
      background: var(--badge-success, #d1fae5);
      color: var(--status-success-text, #12b76a);
    }

    &.icon-orange {
      background: var(--badge-warning, #fef3c7);
      color: var(--status-warning-error, #d97706);
    }

    &.icon-blue {
      background: var(--category-bg-alpha, #eaf0ff);
      color: var(--category-text-alpha, #2563eb);
    }

    &.icon-purple {
      background: var(--bg-selected, #f4effe);
      color: var(--button-primary-bg-default, #7c3aed);
    }
  }

  span {
    font-size: 11px;
    color: var(--text-tertiary, #667085);
  }
}

.btn-dashed {
  background: var(--bg-selected, #f4effe);
  border: 1.5px dashed var(--button-primary-bg-default, #834dd0) !important;
  color: var(--text-link, #834dd0);
  font-weight: 600;

  &:hover {
    background: var(--bg-focus, #e8dffd);
  }
}

/* ===================================
   CERTIFICATES — MY CERTIFICATES TAB
=================================== */

.certificates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;

  margin-bottom: 16px;
}

.certificate-card {
  position: relative;
  overflow: hidden;

  background: linear-gradient(135deg, #1c1140 0%, #150b30 100%);
  color: #fff;

  border-radius: 16px;
  padding: 28px;

  display: flex;
  flex-direction: column;

  &::after {
    content: '';
    position: absolute;
    top: -40px;
    right: -40px;

    width: 140px;
    height: 140px;
    border-radius: 50%;

    background: rgba(255, 255, 255, 0.04);
  }

  .org-name {
    display: block;

    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #f0a83e;

    margin-bottom: 10px;
    padding-right: 40px;
  }

  .cert-badge {
    position: absolute;
    top: 22px;
    right: 22px;

    width: 40px;
    height: 40px;
    border-radius: 10px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: linear-gradient(135deg, #f0a83e, #e2792b);
    color: #fff;

    mat-icon {
      font-size: 19px;
      width: 19px;
      height: 19px;
    }
  }

  .cert-lead {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;

    &.highlight {
      color: #f0a83e;
      font-weight: 500;
    }
  }

  h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
  }

  .cert-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;

    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);

    span {
      display: block;
      font-size: 11px;
      color: rgba(255, 255, 255, 0.55);
      margin-bottom: 4px;
    }

    strong {
      font-size: 13px;
      font-weight: 600;
    }
  }

  .cert-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 22px;
    position: relative;

    .btn-verify {
      margin-left: auto;
    }
  }
}

/* ===================================
   BUTTONS
=================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  border: none;
  border-radius: 8px;

  padding: 9px 16px;
  font-size: 12px;
  font-weight: 500;

  cursor: pointer;
  transition: all 0.15s ease;

  mat-icon {
    font-size: 15px;
    width: 15px;
    height: 15px;
  }

  &.full {
    width: 100%;
    margin-top: 4px;
  }

  &-primary {
    background: var(--button-primary-bg-default, #834dd0);
    color: var(--button-primary-text-default, #fff);
    box-shadow: 0 2px 6px rgba(131, 77, 208, 0.3);

    &:hover {
      background: var(--button-primary-bg-hover, #8a5adb);
    }

    &:active {
      background: var(--button-primary-bg-active, #6f3eb4);
    }
  }

  &-warning {
    background: linear-gradient(90deg, #f0a83e, #e2792b);
    color: #fff;

    &:hover {
      filter: brightness(0.95);
    }
  }

  &-outline {
    background: var(--button-secondary-bg-default, #fff);
    border: 1px solid var(--button-secondary-border-default, #d0d5dd);
    color: var(--button-secondary-text-default, #344054);

    &:hover {
      background: var(--button-secondary-bg-hover, #f9fafb);
    }
  }

  &-ghost {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #fff;

    &:hover {
      background: rgba(255, 255, 255, 0.16);
    }
  }

  &-verify {
    background: linear-gradient(90deg, #f0a83e, #e2792b);
    color: #fff;
    font-weight: 600;

    &:hover {
      filter: brightness(0.95);
    }
  }
}

/* ===================================
   DATA TABLE
=================================== */

.data-table {
  background: var(--bg-surface, #fff);
  border: 1px solid var(--border-subtle, #e8eaef);
  border-radius: 12px;
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.data-table table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.data-table thead {
  background: var(--table-header-bg, #fafbfc);
}

.data-table th {
  text-align: left;
  padding: 14px 18px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-tertiary, #8b97a7);
  font-weight: 700;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  border-top: 1px solid var(--table-border, #edf1f5);
  font-size: 13px;
  vertical-align: middle;

  h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary, #1d2939);
  }

  .muted {
    font-size: 11px;
    color: var(--text-tertiary, #98a2b3);
  }
}

.data-table tbody tr:hover {
  background: var(--bg-hover, #fafcff);
}

.cell-with-icon {
  display: flex;
  align-items: center;
  gap: 10px;

  &.inline {
    display: inline-flex;
    color: var(--text-secondary, #344054);
  }

  .row-icon {
    flex-shrink: 0;

    width: 34px;
    height: 34px;
    border-radius: 9px;

    display: flex;
    align-items: center;
    justify-content: center;

    background: linear-gradient(135deg, var(--button-primary-bg-default, #834dd0), var(--button-primary-bg-active, #6f3eb4));
    color: #fff;

    mat-icon {
      font-size: 17px;
      width: 17px;
      height: 17px;
    }
  }
}

.muted-icon {
  font-size: 14px !important;
  width: 14px !important;
  height: 14px !important;
  color: var(--text-tertiary, #98a2b3);
  margin-right: 2px;
}

.score-cell {
  display: flex;
  align-items: center;
  gap: 10px;

  strong {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-primary, #1d2939);
    white-space: nowrap;
  }
}

.score-bar {
  width: 72px;
  height: 6px;
  flex-shrink: 0;

  background: var(--bg-muted, #e4e7ec);
  border-radius: 20px;
  overflow: hidden;

  .fill {
    height: 100%;

    &.good {
      background: linear-gradient(90deg, var(--button-primary-bg-default, #834dd0), #14b8a6);
    }

    &.bad {
      background: var(--border-error, #ef4444);
    }
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;

  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;

  mat-icon {
    font-size: 13px;
    width: 13px;
    height: 13px;
  }

  &.completed {
    background: var(--badge-success, #d1fae5);
    color: var(--status-success-text, #047857);
  }

  &.progress {
    background: var(--badge-warning, #fef3c7);
    color: var(--status-warning-error, #d97706);
  }

  &.scheduled {
    background: var(--bg-selected, #f4effe);
    color: var(--text-link, #834dd0);
  }

  &.failed {
    background: var(--badge-error, #fee2e2);
    color: var(--status-error-text, #b91c1c);
  }
}

/* ===================================
   EMPTY STATE
=================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;

  color: var(--text-tertiary, #98a2b3);
  font-size: 12px;
  padding: 32px 24px;
  text-align: center;

  .empty-icon {
    font-size: 26px;
    width: 26px;
    height: 26px;
  }
}

/* ===================================
   RESPONSIVE
=================================== */

@media (max-width: 992px) {
  .dashboard-bottom {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 20px 16px;
  }
}

@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    padding: 10px 14px;

    .nav-menu {
      order: 3;
      width: 100%;
      margin-top: 6px;
    }

    .profile .user-info {
      display: none;
    }
  }

  .page-header {
    align-items: flex-start;

    h1 {
      font-size: 20px;
    }

    .btn {
      width: 100%;
    }
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 680px) {
  .data-table table {
    min-width: 0;
  }

  .table-scroll {
    overflow-x: visible;
  }

  .data-table thead {
    display: none;
  }

  .data-table tbody tr {
    display: block;
    padding: 12px 16px;
    border-top: 1px solid var(--table-border, #edf1f5);

    &:first-child {
      border-top: none;
    }
  }

  .data-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;

    border-top: none;
    padding: 6px 0;
    text-align: right;

    &::before {
      content: attr(data-label);

      font-size: 11px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: .4px;
      color: var(--text-tertiary, #8b97a7);
      text-align: left;
    }

    h4, .muted {
      text-align: right;
    }

    .cell-with-icon {
      flex-direction: row-reverse;
    }
  }
}

@media (max-width: 480px) {
  .highlight-card,
  .panel,
  .certificate-card {
    padding: 16px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .certificates-grid {
    grid-template-columns: 1fr;
  }

  .certificate-card .cert-meta {
    gap: 14px;
  }
}
