/* ========================================
   ГЕНЕРАТОР БЕЙДЖІВ ФКіМ ЛНУ
   Стиль: Academic Prestige
   Mobile-First Design
   ======================================== */

/* Google Fonts - Академічна типографіка */
@import url('https://fonts.googleapis.com/css2?family=Source+Serif+4:ital,opsz,wght@0,8..60,400;0,8..60,600;0,8..60,700;1,8..60,400&family=Source+Sans+3:wght@400;500;600;700&family=Caveat:wght@400;700&family=Comfortaa:wght@400;700&family=Montserrat:wght@400;700&family=Open+Sans:wght@400;700&family=Playfair+Display:wght@400;700&family=Roboto:wght@400;700&display=swap');

/* ========================================
   CSS CUSTOM PROPERTIES
   ======================================== */

:root {
    /* University Blue palette */
    --navy-900: #0A1628;
    --navy-800: #122340;
    --navy-700: #1A3156;
    --navy-600: #234578;
    --navy-500: #2D5A9E;
    --navy-400: #4A7DC4;
    --navy-300: #7BA3DB;
    --navy-200: #B3CAE9;
    --navy-100: #E1EBF7;
    --navy-50: #F4F7FB;

    /* Gold accent */
    --gold-500: #B8860B;
    --gold-400: #D4A017;
    --gold-300: #E8C547;

    /* Neutrals */
    --gray-900: #1A1A1A;
    --gray-700: #404040;
    --gray-600: #525252;
    --gray-500: #6B6B6B;
    --gray-400: #8F8F8F;
    --gray-300: #C4C4C4;
    --gray-200: #E0E0E0;
    --gray-100: #F0F0F0;
    --gray-50: #FAFAFA;
    --white: #FFFFFF;

    /* Semantic */
    --bg: var(--gray-50);
    --surface: var(--white);
    --text: var(--gray-900);
    --text-secondary: var(--gray-600);
    --text-muted: var(--gray-400);
    --primary: var(--navy-700);
    --primary-dark: var(--navy-800);
    --primary-light: var(--navy-500);
    --accent: var(--gold-500);
    --border: var(--gray-200);
    --border-dark: var(--gray-300);
    --error: #C53030;
    --success: #276749;

    /* Typography */
    --font-display: 'Source Serif 4', Georgia, serif;
    --font-body: 'Source Sans 3', -apple-system, sans-serif;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);

    /* Radius */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   RESET & BASE
   ======================================== */

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

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ========================================
   CONTAINER
   ======================================== */

.container {
    width: 100%;
    max-width: 100%;
    padding: var(--space-4);
    margin: 0 auto;
}

/* ========================================
   HEADER - Academic with Logo
   ======================================== */

.header {
    background: var(--navy-800);
    color: var(--white);
    padding: var(--space-6) var(--space-4);
    margin: calc(var(--space-4) * -1);
    margin-bottom: var(--space-6);
    text-align: center;
    position: relative;
}

/* Gold bottom border */
.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold-400), transparent);
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.header-logo {
    width: 56px;
    height: 72px;
    object-fit: contain;
}

.header-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
}

.header h1 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.header .subtitle {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.85;
    letter-spacing: 0.01em;
}

/* ========================================
   SECTIONS
   ======================================== */

section {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border);
}

section h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border);
}

.section-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

/* ========================================
   INSTRUCTIONS
   ======================================== */

.instructions {
    background: var(--navy-50);
    border-color: var(--navy-100);
}

.instructions h2 {
    color: var(--navy-700);
}

.instructions ol {
    list-style: none;
    padding: 0;
    counter-reset: step;
}

.instructions li {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-3);
    counter-increment: step;
}

.instructions li:last-child {
    margin-bottom: 0;
}

.instructions li::before {
    content: counter(step);
    min-width: 24px;
    height: 24px;
    background: var(--navy-700);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ========================================
   FORM
   ======================================== */

.form-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-4);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    height: 44px;
    padding: 0 var(--space-3);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--text);
    background: var(--white);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    transition: all 0.2s var(--ease);
    -webkit-appearance: none;
    appearance: none;
}

.form-group textarea {
    height: auto;
    padding: var(--space-3);
    resize: vertical;
    min-height: 100px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 49, 86, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23525252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 44px;
    padding: 0 var(--space-5);
    font-family: var(--font-body);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s var(--ease);
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Primary */
.btn-primary {
    background: var(--navy-700);
    color: var(--white);
}

.btn-primary:hover:not(:disabled) {
    background: var(--navy-800);
}

/* Secondary */
.btn-secondary {
    background: var(--gold-500);
    color: var(--white);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gold-400);
}

/* Outline */
.btn-outline {
    background: var(--white);
    color: var(--text-secondary);
    border: 1px solid var(--border-dark);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

/* Danger */
.btn-danger {
    background: var(--white);
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--error);
    color: var(--white);
}

/* Large */
.btn-large {
    width: 100%;
    height: 48px;
    font-size: 0.9rem;
    border-radius: var(--radius-md);
}

/* Small */
.btn-small {
    height: 32px;
    padding: 0 var(--space-3);
    font-size: 0.75rem;
}

/* ========================================
   ACTIONS SECTION
   ======================================== */

.actions-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: var(--space-4);
}

/* ========================================
   STUDENTS LIST
   ======================================== */

.students-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.student-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius);
    border-left: 3px solid var(--navy-500);
    transition: all 0.2s var(--ease);
}

.student-card:active {
    background: var(--gray-100);
}

.student-info {
    flex: 1;
    min-width: 0;
}

.student-name {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.student-details {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.btn-delete {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: var(--white);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s var(--ease);
}

.btn-delete:hover {
    background: #FEE2E2;
    border-color: var(--error);
    color: var(--error);
}

.empty-message {
    text-align: center;
    padding: var(--space-8) var(--space-4);
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ========================================
   BADGES PREVIEW
   ======================================== */

.badges-preview {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-4);
}

.badge-preview {
    aspect-ratio: 9 / 6;
    background: var(--white);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s var(--ease);
}

.badge-preview:active {
    transform: scale(0.98);
}

.badge-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.badge-logo {
    width: 28px;
    height: 36px;
    object-fit: contain;
    flex-shrink: 0;
}

.badge-qr {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    background: var(--white);
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.badge-qr svg {
    width: 100%;
    height: 100%;
}

.badge-middle-name {
    position: absolute;
    top: 52px;
    right: var(--space-3);
    font-size: 0.9rem;
    color: var(--text-muted);
    text-align: right;
}

.badge-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 0 var(--space-2);
}

.badge-name {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy-800);
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.badge-lastname {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-info {
    position: absolute;
    bottom: var(--space-2);
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ========================================
   MODAL
   ======================================== */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(10, 22, 40, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    padding: 0;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 90vh;
    max-height: 90dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    padding-top: var(--space-6);
    border-bottom: 1px solid var(--border);
    position: relative;
}

.modal-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
}

.modal-header h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
    padding: 0;
    border: none;
}

.modal-close {
    width: 36px;
    height: 36px;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s var(--ease);
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--text);
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.modal-body .help-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-4);
}

.modal-body code {
    font-family: 'SF Mono', monospace;
    font-size: 0.8rem;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    color: var(--navy-700);
}

.modal-body small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.modal-body textarea {
    width: 100%;
    min-height: 150px;
    padding: var(--space-3);
    font-family: 'SF Mono', monospace;
    font-size: 0.875rem;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    resize: vertical;
    background: var(--white);
    color: var(--text);
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 49, 86, 0.15);
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
    background: var(--gray-50);
}

.modal-footer .btn {
    flex: 1;
}

/* ========================================
   GENERATE SECTION
   ======================================== */

.generate-section {
    background: transparent;
    border: none;
    padding: 0;
    margin-top: var(--space-2);
    margin-bottom: var(--space-6);
}

.generate-section .btn-large {
    background: var(--navy-700);
    box-shadow: var(--shadow-md);
}

.generate-section .btn-large:hover:not(:disabled) {
    background: var(--navy-800);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   FOOTER
   ======================================== */

.footer {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    padding-bottom: max(var(--space-6), env(safe-area-inset-bottom));
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    background: var(--white);
    margin: 0 calc(var(--space-4) * -1);
}

/* ========================================
   RESPONSIVE - TABLET (600px+)
   ======================================== */

@media (min-width: 600px) {
    .container {
        padding: var(--space-6);
        max-width: 720px;
    }

    .header {
        margin: calc(var(--space-6) * -1);
        margin-bottom: var(--space-8);
        padding: var(--space-8) var(--space-6);
    }

    .header-content {
        flex-direction: row;
        justify-content: center;
        gap: var(--space-5);
    }

    .header-logo {
        width: 64px;
        height: 84px;
    }

    .header-text {
        align-items: flex-start;
        text-align: left;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header .subtitle {
        font-size: 0.9rem;
    }

    section {
        padding: var(--space-6);
        margin-bottom: var(--space-5);
    }

    section h2 {
        font-size: 1.1rem;
    }

    .form-row {
        flex-direction: row;
        gap: var(--space-4);
    }

    .form-group {
        flex: 1;
    }

    .actions-section {
        flex-direction: row;
        justify-content: center;
        gap: var(--space-3);
    }

    .badges-preview {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-5);
    }

    .badge-preview:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }

    .badge-middle-name {
        font-size: 1rem;
    }

    .badge-name {
        font-size: 1.75rem;
    }

    .badge-lastname {
        font-size: 0.85rem;
    }

    .modal {
        align-items: center;
        padding: var(--space-6);
    }

    .modal-content {
        max-width: 540px;
        max-height: 85vh;
        border-radius: var(--radius-lg);
    }

    .modal-header::before {
        display: none;
    }

    .modal-header {
        padding-top: var(--space-5);
    }

    .modal-footer {
        padding-bottom: var(--space-5);
    }

    .student-card:hover {
        background: var(--gray-100);
    }

    .footer {
        margin: 0 calc(var(--space-6) * -1);
    }
}

/* ========================================
   RESPONSIVE - DESKTOP (900px+)
   ======================================== */

@media (min-width: 900px) {
    .container {
        padding: var(--space-8);
        max-width: 960px;
    }

    .header {
        margin: calc(var(--space-8) * -1);
        margin-bottom: var(--space-10);
        padding: var(--space-10) var(--space-8);
    }

    .header-logo {
        width: 72px;
        height: 96px;
    }

    .header h1 {
        font-size: 1.75rem;
    }

    .header .subtitle {
        font-size: 1rem;
    }

    section {
        padding: var(--space-8);
        margin-bottom: var(--space-6);
    }

    section h2 {
        font-size: 1.2rem;
    }

    .form-group input,
    .form-group select {
        height: 48px;
    }

    .btn {
        height: 48px;
    }

    .btn-large {
        height: 52px;
        font-size: 0.95rem;
    }

    .badges-preview {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-6);
    }

    .badge-preview {
        padding: var(--space-4);
    }

    .badge-logo {
        width: 32px;
        height: 42px;
    }

    .badge-qr {
        width: 52px;
        height: 52px;
    }

    .badge-middle-name {
        font-size: 1.1rem;
    }

    .badge-name {
        font-size: 2rem;
    }

    .badge-lastname {
        font-size: 0.95rem;
    }

    .student-card {
        padding: var(--space-5);
    }

    .student-name {
        font-size: 1rem;
    }

    .student-details {
        font-size: 0.85rem;
    }

    .footer {
        margin: 0 calc(var(--space-8) * -1);
    }
}

/* ========================================
   RESPONSIVE - LARGE DESKTOP (1200px+)
   ======================================== */

@media (min-width: 1200px) {
    .container {
        max-width: 1080px;
    }

    .badges-preview {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ========================================
   FOCUS STATES
   ======================================== */

.btn:focus-visible,
.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ========================================
   REDUCED MOTION
   ======================================== */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .header,
    .instructions,
    .form-section,
    .actions-section,
    .students-section,
    .generate-section,
    .footer,
    .modal {
        display: none !important;
    }

    body {
        background: white;
    }

    .preview-section {
        border: none;
        padding: 0;
        box-shadow: none;
    }

    .badges-preview {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 5mm;
    }

    .badge-preview {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
}
