@import "fonts.css";

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', sans-serif;
    background: #f0f2f8;
    color: #1a1a2e;
}

.print-controls {
    text-align: center;
    padding: 30px 20px;
    background: #fff;
    border-bottom: 1px solid #dce3f0;
}

.print-controls h1 {
    font-size: 1.5rem;
    margin: 10px 0;
}

.print-controls p {
    font-size: 0.9rem;
    color: #64748b;
    max-width: 600px;
    margin: 0 auto 16px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #1155D6;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.btn-print {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 32px;
    background: linear-gradient(135deg, #1155D6, #4d80e8);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
}

.btn-print:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(17,85,214,0.25);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

/* Individual card */
.print-card {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #1a1a2e;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.card-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 75%;
    height: 75%;
}

.card-marker svg {
    width: 100%;
    height: 100%;
}

.card-number {
    position: absolute;
    font-size: 0.45rem;
    font-weight: 900;
    color: #1a1a2e;
    background: rgba(255,255,255,0.9);
    padding: 2px 8px;
    border-radius: 6px;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 0.25em;
    transform-origin: top left;
}

.card-number-top-left    { bottom: 88.6%;                     left: 24px; }
.card-number-top-right   { top: 26px;                        left: calc(88.6% + 1em + 4px); transform: rotate(90deg); }
.card-number-bottom-right{ top: calc(88.6% + 1em + 4px);     left: calc(100% - 24px);       transform: rotate(180deg); }
.card-number-bottom-left { top: calc(100% - 27px);           left: calc(11.4% - 1em - 4px); transform: rotate(-90deg); }

.card-label {
    position: absolute;
    font-size: var(--ls, 0.8rem);
    font-weight: 800;
    color: #1a1a2e;
    line-height: 1;
}

/* Arête interne ancrée à ~1.6% du marker (qui commence à 12.5% de chaque bord) */
.card-label-top    { bottom: 89.1%;                                       left: 50%; transform: translateX(-50%); }
.card-label-bottom { top: 89.1%;                                          left: 50%; transform: translateX(-50%) rotate(180deg); }
.card-label-left   { left:  calc(10.9% - 0.8 * var(--ls, 0.4rem)); top:  50%; transform: translateY(-50%) rotate(-90deg); }
.card-label-right  { right: calc(10.9% - 0.8 * var(--ls, 0.4rem)); top:  50%; transform: translateY(-50%) rotate(90deg); }

/* ========================================
   Options panel (pre-print settings)
   ======================================== */
.card-options {
    max-width: 600px;
    margin: 24px auto;
    padding: 24px 24px;
    background: #f8f9fc;
    border: 1px solid #dce3f0;
    border-radius: 12px;
    text-align: left;
}

.card-options h2 {
    font-size: 1rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.option-group {
    margin-bottom: 16px;
}

.option-group:last-child {
    margin-bottom: 0;
}

.option-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 8px;
}

/* Color picker row */
.color-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.color-row input[type="color"] {
    width: 40px;
    height: 40px;
    border: 2px solid #dce3f0;
    border-radius: 8px;
    padding: 2px;
    cursor: pointer;
    background: #fff;
}

.color-presets {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-preset {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid #dce3f0;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-preset:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.color-preset.active {
    border-color: #1155D6;
    box-shadow: 0 0 0 3px rgba(17,85,214,0.2);
}

/* QR contrast warning */
.qr-contrast-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 12px;
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #92400e;
}

.qr-contrast-warning i {
    color: #f59e0b;
    font-size: 0.9rem;
}

/* Range slider */
.range-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-row input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #dce3f0;
    border-radius: 3px;
    outline: none;
}

.range-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1155D6;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(17,85,214,0.3);
}

.range-row input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1155D6;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(17,85,214,0.3);
}

.range-value {
    font-size: 0.8rem;
    font-weight: 700;
    color: #1155D6;
    min-width: 50px;
    text-align: center;
    background: #eef2ff;
    padding: 4px 8px;
    border-radius: 6px;
}

/* Info banner — shows config from index.html */
.card-config-info {
    max-width: 600px;
    margin: 16px auto;
    padding: 12px 18px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
}

.card-config-info i {
    color: #1155D6;
    font-size: 1rem;
}

.card-config-info .config-info-link {
    margin-left: auto;
    color: #1155D6;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.8rem;
    white-space: nowrap;
    transition: opacity 0.2s;
}

.card-config-info .config-info-link:hover {
    opacity: 0.7;
}

.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    user-select: none;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #dce3f0;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.checkbox-option:hover {
    border-color: #1155D6;
    background: #f0f4ff;
}

.checkbox-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #1155D6;
}

/* ========================================
   Student name — inline in card number pill
   ======================================== */
.card-student-name {
    font-size: 1em;
    font-weight: 600;
    color: inherit;
    max-width: 5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1;
    flex-shrink: 1;
}

/* Print styles */
@page {
    size: A4 portrait;
    margin: 1.5cm;
}

@media print {
    .no-print { display: none !important; }

    body {
        background: white;
        margin: 0;
        padding: 0;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .cards-grid {
        display: block;
        padding: 0;
        margin: 0;
        max-width: 100%;
    }

    .print-card {
        border: 4pt solid black;
        border-radius: 0;
        page-break-after: always;
        /* A4 - 2×1.5cm margins = 18cm de large disponible */
        width: 18cm;
        height: 18cm;
        margin: 0 auto;
    }

    .print-card:last-child {
        page-break-after: auto;
    }

    /* Pas d'override du card-marker : utilise le même 75% qu'à l'écran */

    /* Carte écran ≈ 245px, carte imprimée ≈ 680px → facteur ×2.8 */
    .card-label  { font-size: calc(var(--ls, 0.8rem) * 2.8); }
    .card-number { font-size: calc(0.45rem * 2.8); background: white; padding: 5px 15px; }

    .card-number-top-left    { left: 67px; }
    .card-number-top-right   { top: 73px; left: calc(88.6% + 1em + 10px); }
    .card-number-bottom-right{ top: calc(88.6% + 1em + 10px); left: calc(100% - 67px); }
    .card-number-bottom-left { top: calc(100% - 76px); left: calc(11.4% - 1em - 10px); }

    .card-label-left  { left:  calc(10.9% - 0.8 * var(--ls, 0.4rem) * 2.8); }
    .card-label-right { right: calc(10.9% - 0.8 * var(--ls, 0.4rem) * 2.8); }

    .card-student-name { max-width: none; }

}


