/**
 * Hilanaw Certificate Page Styles
 *
 * @package Hilanaw_Chat_UI
 * @version 3.3.1
 */

/* ── CSS Variables ────────────────────────────────────────────────── */
/* FIX: Moved from .hcert-page to :root so variables resolve immediately
   on first paint — prevents cards/grid rendering without colours/radius */
:root {
    --hcert-green:        #0046a0;
    --hcert-green-light:  #0066cc;
    --hcert-green-bg:     #f0f4ff;
    --hcert-navy:         #1a2e6b;
    --hcert-navy-light:   #2d4aaa;
    --hcert-navy-bg:      #f0f2fb;
    --hcert-gold:         #b8860b;
    --hcert-gold-light:   #d4af37;
    --hcert-gold-bg:      #fdfbf4;
    --hcert-locked:       #aaaaaa;
    --hcert-locked-bg:    #f5f5f5;
    --hcert-text:         #1a1a1a;
    --hcert-text-muted:   #888888;
    --hcert-border:       #e8e8e8;
    --hcert-radius:       10px;
    --hcert-shadow:       0 2px 16px rgba(0,0,0,0.08);
    --hcert-shadow-hover: 0 8px 32px rgba(0,0,0,0.14);
}

.hcert-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px 60px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* ── Page Header ──────────────────────────────────────────────────── */
.hcert-header {
    background: linear-gradient(135deg, #002d6b 0%, #0046a0 50%, #0066cc 100%);
    border-radius: var(--hcert-radius);
    padding: 32px 36px;
    margin-bottom: 36px;
    color: #ffffff;
}

.hcert-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
}

.hcert-header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hcert-header-icon {
    font-size: 40px;
    line-height: 1;
}

.hcert-page-title {
    font-size: 26px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 4px;
    border: none;
    padding: 0;
}

.hcert-page-sub {
    font-size: 13px;
    color: rgba(255,255,255,0.65);
    margin: 0;
    letter-spacing: 0.5px;
}

/* Progress summary */
.hcert-progress-summary {
    text-align: right;
    min-width: 160px;
}

.hcert-progress-nums {
    font-size: 32px;
    font-weight: 700;
    color: #ffffff;
    line-height: 1;
    margin-bottom: 4px;
}

.hcert-progress-sep {
    color: rgba(255,255,255,0.4);
    margin: 0 2px;
}

.hcert-progress-total {
    font-size: 22px;
    color: rgba(255,255,255,0.6);
}

.hcert-progress-label {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.hcert-progress-bar-wrap {
    height: 5px;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.hcert-progress-bar {
    height: 100%;
    background: #ffffff;
    border-radius: 3px;
    transition: width 0.6s ease;
    min-width: 2px;
}

.hcert-progress-pct {
    font-size: 11px;
    color: rgba(255,255,255,0.55);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ── Section ──────────────────────────────────────────────────────── */
.hcert-section {
    margin-bottom: 48px;
}

.hcert-section-header {
    margin-bottom: 20px;
}

.hcert-section-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--hcert-text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px;
    border: none;
    padding: 0;
}

.hcert-section-icon {
    font-size: 18px;
}

.hcert-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--hcert-green-bg);
    color: var(--hcert-green);
    font-size: 12px;
    font-weight: 700;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.hcert-section--locked .hcert-section-count {
    background: #f5f5f5;
    color: var(--hcert-locked);
}

.hcert-section-sub {
    font-size: 13px;
    color: var(--hcert-text-muted);
    margin: 0;
}

/* ── Certificate Grid ─────────────────────────────────────────────── */
.hcert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ── Certificate Card — Base ──────────────────────────────────────── */
.hcert-card {
    background: #ffffff;
    border-radius: var(--hcert-radius);
    border: 1.5px solid var(--hcert-border);
    box-shadow: var(--hcert-shadow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.hcert-card--earned:hover {
    box-shadow: var(--hcert-shadow-hover);
    transform: translateY(-2px);
}

/* ── Accent top strip based on type ──────────────────────────────── */
.hcert-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.hcert-card--level::before  { background: linear-gradient(90deg, var(--hcert-green), var(--hcert-green-light)); }
.hcert-card--track::before  { background: linear-gradient(90deg, var(--hcert-navy), var(--hcert-navy-light)); }
.hcert-card--master::before { background: linear-gradient(90deg, var(--hcert-gold), var(--hcert-gold-light)); }

/* ── Type badge ───────────────────────────────────────────────────── */
.hcert-card-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 3px;
    align-self: flex-start;
}

.hcert-card--level .hcert-card-badge  { background: var(--hcert-green-bg); color: var(--hcert-green); }
.hcert-card--track .hcert-card-badge  { background: var(--hcert-navy-bg);  color: var(--hcert-navy); }
.hcert-card--master .hcert-card-badge { background: var(--hcert-gold-bg);  color: var(--hcert-gold); }

.hcert-card-badge--locked {
    background: #f5f5f5 !important;
    color: var(--hcert-locked) !important;
}

/* ── Card icon ────────────────────────────────────────────────────── */
.hcert-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
}

.hcert-card--level .hcert-card-icon  { background: var(--hcert-green-bg); color: var(--hcert-green); }
.hcert-card--track .hcert-card-icon  { background: var(--hcert-navy-bg);  color: var(--hcert-navy); }
.hcert-card--master .hcert-card-icon { background: var(--hcert-gold-bg);  color: var(--hcert-gold); }
.hcert-card-icon--locked             { background: #f5f5f5; }

/* ── Card body ────────────────────────────────────────────────────── */
.hcert-card-body {
    flex: 1;
}

.hcert-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--hcert-text);
    margin: 0 0 4px;
    line-height: 1.3;
    border: none;
    padding: 0;
}

.hcert-card-title--locked {
    color: var(--hcert-locked);
}

.hcert-card-level {
    font-size: 12px;
    color: var(--hcert-text-muted);
    margin: 0 0 10px;
    letter-spacing: 0.5px;
}

.hcert-card-level--locked {
    color: #cccccc;
}

.hcert-card-stats {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--hcert-text-muted);
    margin-bottom: 8px;
}

.hcert-card-stat strong {
    color: var(--hcert-text);
    font-weight: 700;
}

.hcert-card-stat-sep {
    color: var(--hcert-border);
}

.hcert-card-date {
    font-size: 11px;
    color: var(--hcert-text-muted);
    margin: 0 0 4px;
}

.hcert-card-id {
    font-family: 'Courier New', Courier, monospace;
    font-size: 10px;
    color: #cccccc;
    margin: 0;
    letter-spacing: 0.5px;
}

.hcert-card-locked-msg {
    font-size: 12px;
    color: var(--hcert-locked);
    margin: 0;
    font-style: italic;
}

/* ── Card actions ─────────────────────────────────────────────────── */
.hcert-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.hcert-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: opacity 0.2s, background 0.2s;
    white-space: nowrap;
}

.hcert-btn:hover { opacity: 0.88; }

.hcert-btn--download {
    background: #0046a0;
    color: #ffffff;
}

.hcert-card--track .hcert-btn--download {
    background: var(--hcert-navy);
}

.hcert-card--master .hcert-btn--download {
    background: var(--hcert-gold);
}

.hcert-btn--download.loading {
    opacity: 0.6;
    pointer-events: none;
}

.hcert-btn--verify {
    background: transparent;
    color: var(--hcert-text-muted);
    border: 1.5px solid var(--hcert-border);
}

.hcert-btn--verify:hover {
    color: var(--hcert-text);
    border-color: #cccccc;
}

/* ── Locked card overlay ──────────────────────────────────────────── */
.hcert-card--locked {
    opacity: 0.6;
    cursor: default;
}

.hcert-card--locked:hover {
    box-shadow: var(--hcert-shadow);
    transform: none;
}

/* ── Empty state ──────────────────────────────────────────────────── */
.hcert-empty {
    text-align: center;
    padding: 64px 24px;
    background: #ffffff;
    border-radius: var(--hcert-radius);
    border: 1.5px dashed var(--hcert-border);
    margin-bottom: 48px;
}

.hcert-empty-icon {
    font-size: 52px;
    margin-bottom: 16px;
    line-height: 1;
}

.hcert-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--hcert-text);
    margin: 0 0 10px;
    border: none;
    padding: 0;
}

.hcert-empty-text {
    font-size: 15px;
    color: var(--hcert-text-muted);
    max-width: 420px;
    margin: 0 auto 24px;
    line-height: 1.6;
}

.hcert-empty-btn {
    display: inline-block;
    padding: 12px 28px;
    background: var(--hcert-green);
    color: #ffffff;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: opacity 0.2s;
}

.hcert-empty-btn:hover {
    opacity: 0.88;
    color: #ffffff;
}

/* ── Login prompt ─────────────────────────────────────────────────── */
.hcert-login-prompt {
    text-align: center;
    padding: 64px 24px;
}

.hcert-login-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ── Download toast ───────────────────────────────────────────────── */
.hcert-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: #1a1a1a;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    z-index: 99999;
    opacity: 0;
    transition: transform 0.3s, opacity 0.3s;
    white-space: nowrap;
    pointer-events: none;
}

.hcert-toast.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .hcert-header { padding: 24px 20px; }
    .hcert-header-inner { flex-direction: column; align-items: flex-start; }
    .hcert-progress-summary { text-align: left; }
    .hcert-grid { grid-template-columns: 1fr; }
    .hcert-page-title { font-size: 20px; }
}


/* ── Theme color overrides ────────────────────────────────────────────── */
/* Force white on known children of the blue header — prevents theme from   */
/* overriding with its own blue/dark heading colors. Explicit selectors are  */
/* used instead of .hcert-header * {} so future child elements are not       */
/* silently locked to white.                                                 */
.hcert-header,
.hcert-header-inner,
.hcert-header-left,
.hcert-header-icon,
.hcert-page-title,
.hcert-progress-summary,
.hcert-progress-nums,
.hcert-progress-bar-wrap,
.hcert-progress-bar {
    color: #ffffff !important;
}

.hcert-page-sub,
.hcert-progress-label,
.hcert-progress-pct,
.hcert-progress-sep,
.hcert-progress-total {
    color: rgba(255,255,255,0.78) !important;
}

/* Continue Learning button — always white text on blue background */
.hcert-empty-btn,
.hcert-empty-btn:link,
.hcert-empty-btn:visited,
.hcert-empty-btn:hover,
.hcert-empty-btn:focus,
.hcert-empty-btn:active {
    color: #ffffff !important;
    background: #0046a0 !important;
    text-decoration: none !important;
}

/* ── Certificate page auth panel wrapper ──────────────────────────────── */
.hilanaw-cert-auth-wrap {
    max-width: 480px;
    margin: 60px auto;
    padding: 0 20px;
}

.hilanaw-cert-auth-wrap .hilanaw-login-prompt {
    flex: none;
    display: block;
    text-align: center;
    padding: 48px 24px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    margin-bottom: 16px;
}

.hilanaw-cert-auth-wrap .hilanaw-login-prompt.is-hiding {
    display: none;
}

.hilanaw-cert-auth-wrap .hilanaw-auth-panel {
    flex: none;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    overflow: hidden;
    display: none;
}

.hilanaw-cert-auth-wrap .hilanaw-auth-panel.is-visible {
    display: block;
}

.hilanaw-cert-auth-wrap #hilanaw-forgot-panel {
    display: none;
    flex: none;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(0,0,0,0.08);
    overflow: hidden;
}

.hilanaw-cert-auth-wrap #hilanaw-forgot-panel.is-visible {
    display: block;
}

.hilanaw-cert-auth-wrap .hilanaw-auth-inner {
    max-width: 100%;
    padding: 28px 24px;
}

.hilanaw-cert-auth-wrap .hcert-auth-prompt h2 {
    color: #111827 !important;
    font-size: 22px;
    margin-bottom: 8px;
}

.hilanaw-cert-auth-wrap .hcert-auth-prompt p {
    color: #6b7280 !important;
    margin-bottom: 24px;
}

/* Reload overlay */
.hilanaw-cert-auth-wrap .hilanaw-reload-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.hilanaw-cert-auth-wrap .hilanaw-reload-overlay.is-visible {
    display: flex;
}

/* ── First/Last name side-by-side row ─────────────────────────────────── */
.hilanaw-auth-field-row {
    display: flex;
    gap: 12px;
}

.hilanaw-auth-field-row .hilanaw-auth-field {
    flex: 1;
    min-width: 0;
}

@media (max-width: 400px) {
    .hilanaw-auth-field-row {
        flex-direction: column;
        gap: 0;
    }
}

/* ── Prevent flash of unstyled content on page load ──────────────────── */
/* FIX: Added min-height so the browser reserves layout space while        */
/* opacity is 0 — prevents the container collapsing then jumping open      */
#hilanaw-cert-page {
    opacity: 0;
    transition: opacity 0.25s ease;
    min-height: 60vh;
}

#hilanaw-cert-page.hcert-ready {
    opacity: 1;
    min-height: 0; /* release reserved height once content is visible */
}


/* ============================================================
   CERTIFICATE GATE  (logged-out state)
   ============================================================ */

.hcert-gate {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: clamp(400px, 60vh, 700px);
    padding: clamp(32px, 6vw, 64px) clamp(16px, 4vw, 24px);
    box-sizing: border-box;
}

.hcert-gate-inner {
    width: 100%;
    max-width: 480px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hcert-gate-icon {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 20px;
}

.hcert-gate-title {
    font-size: clamp(20px, 4vw, 26px);
    font-weight: 700;
    color: #111827;
    margin: 0 0 12px;
    line-height: 1.3;
}

.hcert-gate-text {
    font-size: 15px;
    color: #6b7280;
    line-height: 1.6;
    margin: 0 0 28px;
    max-width: 380px;
}

.hcert-gate-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 28px;
    background: #0046a0 !important;
    color: #ffffff !important;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none !important;
    transition: background 0.18s ease, transform 0.15s ease;
    margin-bottom: 16px;
}

.hcert-gate-btn:hover {
    background: #003d8f !important;
    transform: translateY(-1px);
    color: #ffffff !important;
    text-decoration: none !important;
}

.hcert-gate-sub {
    font-size: 13px;
    color: #9ca3af;
    margin: 0;
}

.hcert-gate-sub a {
    color: #0046a0;
    text-decoration: none;
    font-weight: 500;
}

.hcert-gate-sub a:hover {
    text-decoration: underline;
}

/* Dark mode */
body.hilanaw-dark .hcert-gate-title             { color: #f3f4f6; }
body.hilanaw-dark .hcert-gate-text              { color: #9ca3af; }
body.hilanaw-dark .hcert-gate-btn               { background: #0046a0 !important; color: #ffffff !important; }
body.hilanaw-dark .hcert-gate-btn:hover         { background: #003d8f !important; color: #ffffff !important; }
body.hilanaw-dark .hcert-gate-sub               { color: #6b7280; }
body.hilanaw-dark .hcert-gate-sub a             { color: #60a5fa; }

@media (prefers-color-scheme: dark) {
    body:not(.hilanaw-light) .hcert-gate-title         { color: #f3f4f6 !important; }
    body:not(.hilanaw-light) .hcert-gate-text          { color: #9ca3af !important; }
    body:not(.hilanaw-light) .hcert-gate-btn           { background: #0046a0 !important; color: #ffffff !important; }
    body:not(.hilanaw-light) .hcert-gate-btn:hover     { background: #003d8f !important; color: #ffffff !important; }
    body:not(.hilanaw-light) .hcert-gate-sub           { color: #6b7280 !important; }
    body:not(.hilanaw-light) .hcert-gate-sub a         { color: #60a5fa !important; }
}
