/* =========================================
   DOCUMENTS.CSS (Digital Diploma UI)
   ========================================= */

/* --- 1. PAGE CONTROLS --- */
.doc-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    background: white;
    padding: 24px 32px;
    border-radius: 16px;
    border: 1px solid var(--border-light);
    box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}

/* --- 2. LOCKED MASTER BANNER --- */
.locked-certificate {
    background: #F8FAFC;
    border: 2px dashed #CBD5E1;
    border-radius: 16px;
    padding: 20px 24px;
    display: flex;
    flex-direction: row; 
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 32px;
    width: 100%;
}

.locked-progress-container {
    width: 100%;
    min-width: 200px;
    max-width: 280px; 
}

.locked-progress-bg {
    width: 100%;
    height: 8px;
    background: #E2E8F0;
    border-radius: 10px;
    overflow: hidden;
}

.locked-progress-fill {
    height: 100%;
    background: #94A3B8;
    border-radius: 10px;
    transition: width 1s ease;
}

@media (max-width: 768px) {
    /* 1. Fix the Header squishing issue caused by iOS Safe Areas */
    .top-bar {
        height: auto !important; 
        min-height: var(--topbar-height);
        padding-top: calc(env(safe-area-inset-top) + 12px) !important;
        padding-bottom: 12px !important;
    }
    
    /* 2. Truncate long titles so they don't push the profile menu off-screen */
    .page-title h3 {
        font-size: 18px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 140px; 
    }

    /* 3. Your existing Document controls fixes */
    .doc-controls { 
        flex-direction: column; 
        gap: 20px; 
        text-align: center; 
        padding: 20px; 
    }
    
    .locked-certificate {
        flex-direction: column; 
        align-items: stretch;   
        padding: 16px;          
        gap: 16px;              
    }
    
    .locked-progress-container {
        max-width: 100%;        
    }
}


/* --- 3. CERTIFICATE LIST CARDS --- */
.cert-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.cert-card {
    background: white;
    border: 1px solid var(--border-light);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cert-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0,0,0,0.06);
}

.cert-card-master {
    background: linear-gradient(135deg, #FEF3C7, #FDE68A);
    border: 1px solid #FCD34D;
}


/* --- 4. MODAL POPUP --- */
.modal-overlay { 
    position: fixed; inset: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px); 
    z-index: 1000; display: flex; align-items: center; justify-content: center; 
    opacity: 0; pointer-events: none; transition: 0.3s ease; padding: 20px; 
}

.modal-overlay.active { 
    opacity: 1; 
    pointer-events: auto; 
}

.modal-content-cert {
    width: 100%;
    max-width: 900px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translateY(20px);
    transition: 0.3s ease;
}

.modal-overlay.active .modal-content-cert { 
    transform: translateY(0); 
}

/* Custom Scrollbar for Modal content on Windows */
#modal-certificate-render-area::-webkit-scrollbar { height: 8px; }
#modal-certificate-render-area::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 10px; }
#modal-certificate-render-area::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
#modal-certificate-render-area::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* --- 5. PREMIUM CERTIFICATE DESIGN --- */
.certificate-frame {
    width: 850px;
    min-width: 850px;
    height: 600px;
    background: #FFFFFF;
    padding: 30px;
    margin: 0 auto;
}

/* Outer Navy Border */
.certificate-inner {
    width: 100%;
    height: 100%;
    border: 3px solid #0F172A; 
    padding: 8px; 
    background: #FFFFFF;
}

/* Inner Gold Border & Ivory Background */
.certificate-core {
    width: 100%;
    height: 100%;
    border: 1px solid #D4AF37; 
    background: #FAFAFA; 
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 60px;
    position: relative;
    text-align: center;
}

/* Typography Hierarchy */
.cert-header { margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.cert-org { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 13px; font-weight: 800; letter-spacing: 0.3em; color: #64748B; text-transform: uppercase; }

.cert-title { font-family: 'Playfair Display', serif; font-size: 42px; font-weight: 700; color: #0F172A; margin: 12px 0 20px 0; text-transform: uppercase; letter-spacing: 0.05em; }
.cert-subtitle { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 15px; color: #64748B; letter-spacing: 0.05em; }

.cert-name { font-family: 'Playfair Display', serif; font-size: 48px; color: #D4AF37; margin: 20px 0; font-style: italic; font-weight: 600; line-height: 1.2; border-bottom: 1px solid #E2E8F0; padding-bottom: 8px; min-width: 400px; }

.cert-text { font-size: 15px; color: #334155; max-width: 650px; line-height: 1.7; font-family: 'Plus Jakarta Sans', sans-serif; margin: 0 auto; }

/* Footer Layout (QR, Signature, Seal) */
.cert-footer { display: flex; justify-content: space-between; align-items: flex-end; width: 100%; margin-top: auto; }

/* QR Code Block */
.cert-qr-block { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.cert-qr-box { width: 78px; height: 78px; background: white; padding: 4px; border: 1px solid #CBD5E1; border-radius: 4px; display: flex; align-items: center; justify-content: center; }
.cert-qr-label { font-size: 10px; font-weight: 800; color: #0F172A; letter-spacing: 0.1em; }
.cert-id-text { font-size: 9px; font-family: monospace; color: #94A3B8; margin-top: 2px; text-align: left; }

/* Signature Block */
.cert-sig-block { display: flex; flex-direction: column; align-items: center; margin-bottom: 15px; }
.cert-date { font-family: 'Playfair Display', serif; font-size: 18px; font-style: italic; color: #0F172A; margin-bottom: 6px; }
.cert-sig-line { width: 220px; height: 1px; background: #0F172A; margin-bottom: 8px; }
.cert-sig-label { font-size: 12px; font-weight: 700; color: #475569; text-transform: uppercase; letter-spacing: 0.1em; }

/* Premium Gold Seal */
.premium-seal { width: 110px; height: 110px; position: relative; margin-bottom: 5px; }
.premium-seal-inner {
    width: 100%; height: 100%;
    background: radial-gradient(circle, #FDE68A 0%, #D4AF37 60%, #B45309 100%);
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.9);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    box-shadow: 0 8px 16px rgba(180, 83, 9, 0.25);
    color: #78350F;
    position: relative; z-index: 2;
}
.seal-hrs { font-family: 'Playfair Display', serif; font-size: 32px; font-weight: 800; line-height: 1; }
.seal-txt { font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 4px; line-height: 1.2; }
.seal-ribbon { position: absolute; width: 24px; height: 45px; background: #92400E; bottom: -15px; z-index: 1; box-shadow: 0 4px 6px rgba(0,0,0,0.2); }
.seal-ribbon.left { left: 20px; transform: rotate(25deg); }
.seal-ribbon.right { right: 20px; transform: rotate(-25deg); }

/* Theme Overrides for Master Certificate */
.master-theme .certificate-inner { border-color: #B45309; }
.master-theme .cert-title { color: #92400E; }
.master-theme .cert-name { color: #B45309; border-bottom-color: #FDE68A; }