/* ==================================================
   Card Page - Fullscreen Landscape
   ================================================== */

/* ซ่อน Footer เฉพาะหน้าบัตร */
body:has(.student-card-wrapper) footer {
    display: none !important;
}

/* Card เต็มจอแนวนอน */
@media (orientation: landscape) and (max-width: 768px) {
    .student-card-wrapper {
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem 0;
    }
    
    .sskru-card {
        max-width: 95vw;
        max-height: 90vh;
    }
}

/* Tablet Landscape */
@media (orientation: landscape) and (min-width: 769px) and (max-width: 1024px) {
    .student-card-wrapper {
        min-height: 85vh;
        display: flex;
        align-items: center;
    }
    
    .sskru-card {
        max-width: 85vw;
    }
}

/* ==================================================
   SSKRU Student Card (Fixed Aspect Ratio 1.586:1)
   ================================================== */
.student-card-wrapper {
    display: flex;
    justify-content: center;
    padding: 20px 0;
    transform-origin: top center;
    transition: transform 0.3s ease;
}

.sskru-card {
    position: relative;
    width: 100%;
    max-width: 700px;
    aspect-ratio: 1.586 / 1;
    background: linear-gradient(135deg, 
        #F4C430 0%, 
        #FFD966 25%, 
        #FFFFFF 50%,
        #FFFEF7 100%);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(212, 175, 55, 0.4),
                0 5px 15px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform-origin: top center;
    transition: transform 0.3s ease;
}

/* Background Pattern */
.card-bg-pattern {
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(244, 196, 48, 0.3) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 217, 102, 0.2) 0%, transparent 50%);
    opacity: 0.6;
    pointer-events: none;
}

/* Header Section */
.card-header-section {
    position: relative;
    display: flex;
    align-items: flex-start;
    padding: 1.5% 2.5% 1% 2.5%;
    gap: 1.5%;
    background: linear-gradient(to bottom, 
        rgba(255, 255, 255, 0.9) 0%, 
        rgba(255, 255, 255, 0.5) 100%);
    border-bottom: 2px solid rgba(212, 175, 55, 0.3);
    min-height: 0;
}

.logo-section {
    width: 12%;
    aspect-ratio: 180 / 223;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    margin-right: -3.5%;
}

.university-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    filter: drop-shadow(0 3px 6px rgba(0,0,0,0.2));
}

.logo-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #D4AF37, #F4C430);
    border-radius: 50%;
}

.logo-fallback i {
    font-size: clamp(1.5rem, 5vw, 3rem);
    color: #ffffff;
}

.university-title {
    flex: 1;
    text-align: center;
    align-self: center;
}

.uni-th {
    font-size: clamp(0.75rem, 1.5vw, 1.1rem);
    font-weight: 800;
    color: #2C3E50;
    line-height: 1.1;
    text-shadow: 1px 1px 2px rgba(255,255,255,0.8);
}

.uni-en {
    font-size: clamp(0.55rem, 1vw, 0.75rem);
    font-weight: 600;
    color: #7F8C8D;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.photo-section {
    width: 13%;
    flex-shrink: 0;
    position: relative;
    z-index: 5;
    align-self: flex-end;
    margin-bottom: -0.2%;
    margin-left: -2%;
}

.photo-frame-sskru {
    width: 100%;
    aspect-ratio: 0.786;
    border: 3px solid #0D6EFD;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4),
                0 0 0 2px #D4AF37;
    background: #F8F9FA;
}

.photo-frame-sskru img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Body Section - 2 Column Grid */
.card-body-section {
    position: relative;
    flex: 1;
    padding: 2.5% 3% 2% 3%;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    overflow: hidden;
}

.card-body-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 3%;
    width: 100%;
    align-content: start;
}

/* ซ้าย: ข้อมูลหลัก */
.card-left-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 0;
}

.main-info-section {
    display: flex;
    flex-direction: column;
    gap: 2.5%;
}

.info-item-main {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.info-item-main label {
    font-size: clamp(0.52rem, 0.9vw, 0.68rem);
    color: #7F8C8D;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1;
}

.value-large {
    font-size: clamp(0.85rem, 1.45vw, 1.1rem);
    color: #2C3E50;
    font-weight: 800;
    line-height: 1.2;
}

.value-highlight {
    font-size: clamp(0.95rem, 1.6vw, 1.25rem);
    color: #D4AF37;
    font-weight: 800;
    line-height: 1.1;
}

.value-normal {
    font-size: clamp(0.7rem, 1.2vw, 0.9rem);
    color: #2C3E50;
    font-weight: 600;
    line-height: 1.25;
}

.value-small {
    font-size: clamp(0.6rem, 1vw, 0.75rem);
    color: #2C3E50;
    font-weight: 600;
    line-height: 1.2;
}

/* ขวา: Card ย่อย + Barcode */
.card-right-col {
    display: flex;
    flex-direction: column;
    gap: 2.5%;
    min-height: 0;
}

.info-card-secondary {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.95) 0%, 
        rgba(248, 249, 250, 0.95) 100%);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 5%;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    gap: 3.5%;
}

.info-row-secondary {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.info-row-secondary label {
    font-size: clamp(0.48rem, 0.8vw, 0.6rem);
    color: #7F8C8D;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    line-height: 1;
}

.value-secondary {
    font-size: clamp(0.75rem, 1.25vw, 0.92rem);
    color: #2C3E50;
    font-weight: 700;
    line-height: 1.2;
}

.value-small-secondary {
    font-size: clamp(0.6rem, 0.95vw, 0.72rem);
    color: #2C3E50;
    font-weight: 600;
    line-height: 1.25;
}

.divider-line {
    height: 1px;
    background: linear-gradient(to right, 
        transparent 0%, 
        rgba(212, 175, 55, 0.4) 50%, 
        transparent 100%);
    margin: 2% 0;
}

.barcode-section-card {
    background: linear-gradient(135deg,
        rgba(248, 249, 250, 0.95) 0%,
        rgba(255, 255, 255, 0.95) 100%);
    border: 2px solid rgba(212, 175, 55, 0.3);
    border-radius: 10px;
    padding: 3.5%;
    text-align: center;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

.barcode-wrapper-inline {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    margin-bottom: 0.5rem;
}

.barcode-wrapper-inline svg {
    width: 100%;
    height: auto;
    max-height: 45px;
}

.barcode-label-small {
    font-size: clamp(0.55rem, 0.95vw, 0.7rem);
    color: #7F8C8D;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Badge adjustment */
.info-row-secondary .badge {
    padding: 0.45rem 0.7rem;
    font-size: clamp(0.65rem, 1.05vw, 0.8rem);
    font-weight: 700;
}

/* ==================================================
   Responsive - Safari iOS Optimized
   ================================================== */

/* Desktop */
@media (min-width: 1201px) {
    .student-card-wrapper {
        transform: none;
    }
}

/* Desktop กลาง */
@media (min-width: 993px) and (max-width: 1200px) {
    .sskru-card {
        max-width: 650px;
    }
}

/* Tablet Portrait */
@media (orientation: portrait) and (min-width: 769px) and (max-width: 992px) {
    .sskru-card {
        max-width: 550px;
    }
}

/* Mobile ใหญ่ - Portrait only */
@media (orientation: portrait) and (min-width: 481px) and (max-width: 768px) {
    .sskru-card {
        max-width: 480px;
    }
}

/* Mobile กลาง - Portrait only */
@media (orientation: portrait) and (min-width: 376px) and (max-width: 480px) {
    .sskru-card {
        max-width: 360px;
    }
    
    .student-card-wrapper {
        padding: 10px 0;
    }
}

/* Mobile เล็ก - Portrait only */
@media (orientation: portrait) and (max-width: 375px) {
    .sskru-card {
        max-width: 340px;
    }
    
    .student-card-wrapper {
        padding: 5px 0;
    }
}

/* Safari iOS Specific Fixes */
@supports (-webkit-touch-callout: none) {
    /* iPhone/iPad Safari only */
    .sskru-card {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        will-change: transform;
    }
    
    .university-logo,
    .photo-frame-sskru img {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* Print */
@media print {
    body * {
        visibility: hidden;
    }
    
    .student-card-wrapper,
    .student-card-wrapper * {
        visibility: visible;
    }
    
    .student-card-wrapper {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) !important;
        padding: 0;
    }
    
    .btn, h4 {
        display: none !important;
    }
    
    .sskru-card {
        box-shadow: none;
        border: 1px solid #ddd;
        max-width: 700px !important;
    }
}
/* ==================================================
   Card Footer - Generated By
   ================================================== */
.card-footer-generated {
    position: relative;
    padding: 0.75% 2.5% 0.5% 2.5%;
    background: rgba(248, 249, 250, 0.8);
    border-top: 1px solid rgba(212, 175, 55, 0.2);
    text-align: right;
    font-size: clamp(0.45rem, 0.75vw, 0.55rem);
    color: rgba(44, 62, 80, 0.6);
    font-weight: 500;
    letter-spacing: 0.3px;
}

.card-footer-generated i {
    color: rgba(212, 175, 55, 0.7);
    font-size: clamp(0.5rem, 0.8vw, 0.6rem);
}

.card-footer-generated span {
    font-family: 'Courier New', monospace;
}