:root {
    --primary-blue: #003366;
    /* Approximation of Maseno Navy */
    --accent-gold: #D0BA8E;
    /* Sorrell Brown */
    --text-dark: #1F2937;
    --text-light: #F3F4F6;
    --bg-color: #F8FAFC;
    --card-bg: #FFFFFF;
    --border-radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    min-height: 100vh;
}

/* Header */
.main-header {
    background-color: var(--primary-blue);
    color: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
}

.logo-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.uni-logo {
    height: 60px;
    width: auto;
    background: white;
    padding: 2px;
    border-radius: 5px;
}

.main-header h1 {
    font-size: 1.5rem;
    line-height: 1.2;
}

.subtitle {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--accent-gold);
}

/* Main Layout */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1rem;
    padding: 0 1rem;
    /* Grid removed for mobile-first single screen flow, handled by JS toggling if needed or responsive media queries */
    display: block;
}

/* Screen Management */
.screen {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
    width: 100%;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Form Section */
.form-section {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.form-section h2,
.preview-section h2 {
    margin-bottom: 1.5rem;
    color: var(--primary-blue);
    border-bottom: 2px solid var(--accent-gold);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
}

input,
select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(0, 51, 102, 0.2);
}

/* Generated Buttons */
.btn-primary {
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-blue);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 1rem;
    font-size: 1.1rem;
    /* Larger for touch targets */
}

/* Floating Action Bar (optional based on preference, but sticking to inline for now as per plan/design) */


/* Preview Section */
.preview-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow-x: hidden;
    /* Prevent horizontal scroll on mobile if scale calculations are slightly off */

    /* Prevent horizontal scroll on mobile if scale calculations are slightly off */
}

.card-scale-wrapper {
    /* New wrapper to handle the scaling transform independently */
    width: 100%;
    display: flex;
    justify-content: center;
    margin-bottom: 2rem;
    /* Ensure height is reserved so formatted layout doesn't collapse before scale is applied or if using absolute positioning */
    min-height: 250px;
}

.card-wrapper {
    /* Fixed Reference Size: ID-1 Format is approx 85.6mm x 54mm.
       We design at 400px width for good resolution.
       The JS will scale this whole element down to fit the screen. */
    width: 400px;
    height: 250px;
    perspective: 1000px;
    flex-shrink: 0;
    /* Prevent flex box from squishing it */
    transform-origin: top center;
    /* Scale from top center */
}

.id-card-front {
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
}

/* Card Design Details */
.card-header {
    background: var(--primary-blue);
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 1rem;
    justify-content: center;
    gap: 10px;
    position: relative;
    z-index: 2;
}

.card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-gold);
}

.card-logo {
    height: 40px;
    width: 40px;
    background: white;
    border-radius: 50%;
    padding: 2px;
    object-fit: contain;
}

.uni-details {
    color: white;
    text-align: center;
}

.uni-details h3 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.uni-details .tagline {
    font-size: 0.6rem;
    color: var(--accent-gold);
    text-transform: uppercase;
}

.card-body {
    flex: 1;
    display: flex;
    padding: 10px 15px;
    gap: 15px;
    position: relative;
    z-index: 2;
}

.photo-area {
    width: 100px;
    height: 110px;
    border: 2px solid var(--accent-gold);
    border-radius: 4px;
    overflow: hidden;
    background: #eee;
}

.photo-area img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.student-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.student-info h2 {
    font-size: 0.9rem;
    color: var(--primary-blue);
    text-transform: uppercase;
    margin-bottom: 2px;
    line-height: 1.2;
}

.student-info .role {
    font-size: 0.7rem;
    color: white;
    background: var(--accent-gold);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-weight: 600;
    width: fit-content;
}

.info-grid {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.info-item {
    font-size: 0.65rem;
    display: flex;
}

.info-item .label {
    font-weight: 700;
    width: 50px;
    color: #555;
}

.info-item .value {
    color: #000;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.card-footer {
    height: 40px;
    padding: 0 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    z-index: 2;
}

.barcode-area {
    width: 40px;
    height: 40px;
}

/* Override qrcodejs img styles if needed */
.barcode-area img {
    width: 100%;
    height: 100%;
}

.signature-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.signature-text {
    font-family: 'Brush Script MT', 'Cursive', cursive;
    /* Cursive font for signature */
    font-size: 1rem;
    color: #000;
    margin-bottom: 2px;
}

.signature-line {
    width: 100px;
    height: 1px;
    background-color: #000;
    margin-bottom: 2px;
}

.dean-label {
    font-size: 0.5rem;
    font-weight: 700;
    color: var(--primary-blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Watermark/Background Design */
.watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150px;
    height: 150px;
    background: url('https://upload.wikimedia.org/wikipedia/commons/4/4c/Maseno_University_Logo.png') no-repeat center center;
    background-size: contain;
    opacity: 0.05;
    z-index: 1;
    pointer-events: none;
}

.accent-bar {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 60%;
    height: 100%;
    background: linear-gradient(135deg, transparent 70%, rgba(208, 186, 142, 0.1) 100%);
    z-index: 1;
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    background-color: white;
    border: 1px solid var(--primary-blue);
    color: var(--primary-blue);
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--primary-blue);
    color: white;
}

.preview-note {
    font-size: 0.8rem;
    color: #888;
    margin-top: 1rem;
}

/* Responsive */
@media (max-width: 900px) {

    /* In mobile app mode, container doesn't need grid since we show one screen at a time */
    .container {
        display: block;
    }
}