.cgs-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

/* Base styles for the interactive, on-screen card */
.cgs-card-container-screen {
    perspective: 1000px;
    cursor: pointer;
    position: relative;
    border: 2px solid #333;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #f0f2f5, #e0e4eb);
    transition: transform 0.8s ease-in-out;
    transform-style: preserve-3d;
}
.cgs-card-front, .cgs-card-back {
    width: 100%;
    height: 100%;
    position: absolute;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    text-align: center;
}
.cgs-card-front { z-index: 2; }
.cgs-card-back { transform: rotateY(180deg); }
.cgs-card-container-screen.flipped .cgs-card-front { transform: rotateY(-180deg); }
.cgs-card-container-screen.flipped .cgs-card-back { transform: rotateY(0deg); }

/* --- LANDSCAPE DESIGN (Default) --- */
.cgs-card-container-screen.cgs-landscape {
    width: 550px;
    height: 350px;
}
.cgs-landscape .cgs-front-content {
    display: grid;
    grid-template-areas:
        "header photo"
        "main photo"
        "barcode barcode";
    grid-template-columns: 2fr 1fr;
    grid-template-rows: auto 1fr auto;
    width: 100%;
    height: 100%;
    text-align: left;
    padding: 20px;
    box-sizing: border-box;
}
.cgs-landscape .cgs-header { grid-area: header; }
.cgs-landscape .cgs-photo-area { grid-area: photo; display: flex; align-items: center; justify-content: flex-end; }
.cgs-landscape .cgs-main-content { grid-area: main; display: flex; align-items: center; }
.cgs-landscape .cgs-details-and-photo { display: flex; width: 100%; justify-content: center; align-items: center; text-align: center; }
.cgs-landscape .cgs-details-area { text-align: right; padding-right: 20px; }
.cgs-landscape .cgs-barcode-area { grid-area: barcode; display: flex; justify-content: space-between; align-items: flex-end; padding-top: 15px; border-top: 1px dashed #ccc; margin-top: auto; }
.cgs-landscape .cgs-photo-img { width: 120px; height: 120px; }
.cgs-landscape .cgs-photo-placeholder { width: 120px; height: 120px; }

/* --- PORTRAIT DESIGN --- */
.cgs-card-container-screen.cgs-portrait {
    width: 350px;
    height: 550px;
}
.cgs-portrait .cgs-front-content {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 20px;
    align-items: center;
    text-align: center;
}
.cgs-portrait .cgs-header {
    width: 100%;
    flex: 0 0 auto;
    padding-bottom: 20px;
}
.cgs-portrait .cgs-main-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px 0;
}
.cgs-portrait .cgs-details-and-photo {
    flex-direction: column;
}
.cgs-portrait .cgs-details-area {
    text-align: center;
    padding: 10px 0;
}
.cgs-portrait .cgs-photo-area {
    display: flex;
    justify-content: center;
    padding: 15px 0;
}
.cgs-portrait .cgs-photo-img { width: 150px; height: 150px; }
.cgs-portrait .cgs-photo-placeholder { width: 150px; height: 150px; }
.cgs-portrait .cgs-barcode-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    border-top: 1px dashed #ccc;
    margin-top: auto;
}
.cgs-portrait .cgs-company-address { text-align: center; }

/* Common Styles */
.cgs-logo { max-height: 40px; max-width: 100%; margin-right: 15px; border-radius: 4px; }
.cgs-company-name { color: #333; font-weight: bold; font-size: 1.2em; margin: 0; }
.cgs-name { font-size: 1.8rem; margin: 0 0 5px; color: #333; }
.cgs-position { font-size: 1.2rem; color: #7f8c8d; margin: 0 0 5px; }
.cgs-id { font-size: 0.9rem; color: #555; margin: 0; }
.cgs-photo-img, .cgs-photo-placeholder { border-radius: 50%; object-fit: cover; border: 4px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.2); }
.cgs-barcode-img { width: 80px; height: 80px; padding: 5px; background: #fff; border-radius: 5px; }
.cgs-company-address { color: #555; font-size: 0.8em; margin: 0; white-space: pre-wrap; }

/* Back of the card styles (common) */
.cgs-card-back {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}
.cgs-back-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
}
.cgs-back-header { background: #2c3e50; padding: 10px; border-bottom: 2px solid #34495e; text-align: center; }
.cgs-logo-back { max-height: 40px; max-width: 120px; }
.cgs-company-name-back { margin: 0; font-size: 1.2em; color: #fff; }
.cgs-back-details { padding: 20px 0; text-align: left; flex-grow: 1; }
.cgs-back-details h4 { font-size: 1.4rem; margin-top: 0; color: #333; }
.cgs-back-details p { font-size: 1rem; margin: 8px 0; color: #555; }
.cgs-back-barcode-area { text-align: center; padding-top: 15px; border-top: 1px dashed #ccc; }
.cgs-barcode-img-back { width: 80px; height: 80px; padding: 5px; background: #fff; border-radius: 5px; }
.cgs-id-back { font-size: 0.9rem; color: #555; margin: 5px 0 0; }

.cgs-actions { margin-top: 20px; }
.cgs-print-button {
    padding: 12px 24px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.cgs-print-button:hover { background-color: #2980b9; transform: translateY(-2px); }