:root {
    --cert-gold: #d4af37;
    --cert-red: #c41e3a;
    --cert-dark: #000000;
    --cert-bg: #fffef5;
}

.certificate-page {
    padding: 20px;
    max-width: var(--large-width);
    margin: 0 auto;
}

.certificate-container {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 20px;
}

@media (max-width: 1024px) {
    .certificate-container {
        grid-template-columns: 1fr;
    }
}

.certificate-config {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    position: sticky;
    top: 20px;
    height: fit-content;
}

.config-section-title {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f1f5f9;
}

.template-scroll-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.template-scroll-btn {
    width: 36px;
    height: 120px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #64748b;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.template-scroll-btn:hover {
    border-color: var(--cert-gold);
    color: var(--cert-gold);
    background: #fefce8;
}

.template-scroll-btn:active {
    transform: scale(0.95);
}

.template-scroll-wrapper {
    flex: 1;
    overflow: hidden;
    max-width: 100%;
}

.template-options {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.template-options::-webkit-scrollbar {
    display: none;
}

.template-item {
    width: 120px;
    height: 120px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.template-item:hover {
    border-color: var(--cert-gold);
}

.template-item.active {
    border-color: var(--cert-red);
}

.template-item img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    border-radius: 4px;
    object-fit: cover;
}

.config-section {
    margin-bottom: 16px;
}

.config-section label {
    display: block;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
    font-weight: 500;
}

.config-section input[type="text"],
.config-section textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fafafa;
}

.config-section input[type="text"]:focus,
.config-section textarea:focus {
    outline: none;
    border-color: var(--cert-gold);
    background: white;
}

.config-section textarea {
    resize: vertical;
    min-height: 60px;
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn-secondary {
    flex: 1;
    padding: 10px;
    background: #f1f5f9;
    color: #64748b;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-primary {
    flex: 2;
    padding: 10px;
    background: linear-gradient(135deg, var(--cert-red) 0%, #a8162a 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(196, 30, 58, 0.3);
}

.certificate-preview {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    overflow: auto;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.preview-title {
    font-size: 16px;
    font-weight: 600;
    color: #334155;
}

.certificate-wrapper {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 8px;
    padding: 30px;
    position: relative;
    overflow: hidden;
    width: 297mm;
    height: 210mm;
    margin: 0 auto;
    box-sizing: border-box;
}

.certificate-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    padding: 0;
}

.certificate-name {
    font-size: 2rem;
    color: var(--cert-dark);
    font-family: STZhongsong, '华文中宋', serif;
    position: absolute;
    left: 15.5%;
    top: 41.8%;
    margin: 0;
}

.certificate-name span {
    font-size: 2rem;
    font-family: STXingkai, '华文行楷', serif;
    border-bottom: 2px solid var(--cert-dark);
    padding: 0 6px;
}

.certificate-content {
    max-width: 69%;
    font-size: 2rem;
    color: var(--cert-dark);
    font-family: STZhongsong, '华文中宋', serif;
    position: absolute;
    left: 15.5%;
    top: 50.5%;
    margin: 0;
    text-indent: 2em;
}

.certificate-award {
    font-size: 2.5rem;
    color: var(--cert-red);
    line-height: 1.8;
    font-family: STHupo, '华文琥珀', serif;
    position: absolute;
    left: 50%;
    top: 56.1%;
    transform: translateX(-50%);
    margin: 0;
}

.certificate-encouragement {
    font-size: 2rem;
    color: var(--cert-dark);
    font-family: STZhongsong, '华文中宋', serif;
    position: absolute;
    left: 15.5%;
    top: 64.7%;
    margin: 0;
    text-indent: 2em;
}

.certificate-footer {
    position: absolute;
    right: 15.5%;
    top: 71%;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.certificate-issuer {
    text-align: center;
    font-family: STZhongsong, '华文中宋', serif;
}

.certificate-issuer-name {
    font-size: 2rem;
    color: var(--cert-dark);
}

.certificate-date {
    font-size: 2rem;
    color: var(--cert-dark);
}

.certificate-wrapper.vertical {
    width: 210mm;
    height: 297mm;
}

.certificate-wrapper.vertical .certificate-inner {
    padding: 0;
}

.certificate-wrapper.vertical .certificate-name {
    left: 12.4%;
    top: 37.1%;
    margin: 0;
}

.certificate-wrapper.vertical .certificate-content {
    max-width: 75.6%;
    left: 12.4%;
    top: 42.7%;
    margin: 0;
}

.certificate-wrapper.vertical .certificate-award {
    font-size: 4rem;
    top: 52.2%;
    margin: 0;
}

.certificate-wrapper.vertical .certificate-encouragement {
    left: 12.4%;
    top: 62.2%;
    margin: 0;
}

.certificate-wrapper.vertical .certificate-footer {
    right: 12.4%;
    top: 70.0%;
    gap: 0;
    padding: 0;
}

@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        margin: 0;
        padding: 0;
        background: white;
    }
    
    #app > *:not(.app-main),
    .app-main > *:not(.certificate-page),
    .certificate-page > *:not(.certificate-container),
    .certificate-container > *:not(.certificate-preview),
    .certificate-preview > *:not(.certificate-wrapper),
    .footer-content,
    .action-buttons,
    .config-section-title,
    .template-scroll-container,
    .config-section {
        display: none !important;
    }
    
    .certificate-preview {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }
    
    .certificate-wrapper {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0;
        box-shadow: none;
    }
    
    .certificate-inner {
        width: 100%;
        height: 100%;
    }
}