/* ============================================
   DNI KorPerú — Estilos Morados (Versión Completa)
   ============================================ */
* { margin:0; padding:0; box-sizing:border-box; }

:root {
    /* Paleta Morada BTS */
    --primary:      #4a235a;       /* Morado oscuro para textos fuertes */
    --accent:       #9b59b6;       /* Morado del corazón de favoritos */
    --accent-hover: #8e44ad;       /* Morado más oscuro para hover */
    --light-bg:     #f5f0f7;       /* Fondo general con tinte morado */
    --header-bg:    #ede4f0;       /* Fondo de menú/cabecera */
    --card-bg:      #ffffff;
    --text-dark:    #2c3e50;
    --text-light:   #6c757d;
    --border-soft:  #d7cce0;       /* Borde con tinte morado */
    --shadow:       0 10px 30px rgba(155, 89, 182, 0.15);
    --radius:       16px;
    --menu-w:       320px;
    --cabecera-h:   64px;
}

html, body {
    height: 100%;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-dark);
    background: var(--light-bg);
    overflow: hidden;
}

/* Layout Principal */
.app {
    display: grid;
    grid-template-columns: var(--menu-w) 1fr;
    grid-template-rows: var(--cabecera-h) 1fr;
    grid-template-areas:
        "menu header"
        "menu main";
    height: 100%;
}

/* Menú Lateral */
.menu {
    grid-area: menu;
    background: var(--header-bg);
    border-right: 1px solid var(--border-soft);
    padding: 1.5rem;
    overflow-y: auto;
}
.menu-marca { display: flex; align-items: center; gap: 0.6rem; padding-bottom: 1rem; border-bottom: 1px solid var(--border-soft); margin-bottom: 1.5rem; }
.menu-logo { width: 40px; height: 40px; background: #fff; border-radius: 12px; display: grid; place-items: center; box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.menu-marca-texto { font-weight: 800; color: var(--accent); font-size: 1.2rem; letter-spacing: -0.5px; }

/* Formulario */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 800; color: var(--primary); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px; }
.form-control { width: 100%; padding: 0.7rem 0.9rem; border: 2px solid var(--border-soft); border-radius: 10px; font-family: inherit; font-size: 0.95rem; outline: none; transition: border-color 0.2s, box-shadow 0.2s; background: #fff; }
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(155, 89, 182, 0.15); }
select.form-control { cursor: pointer; }

/* Cabecera */
.cabecera {
    grid-area: header;
    background: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    box-shadow: 0 2px 12px rgba(155, 89, 182, 0.1);
    z-index: 10;
    border-bottom: 1px solid var(--border-soft);
}
.cabecera-titulo { font-size: 1.2rem; font-weight: 800; color: var(--primary); }

/* Área Principal */
.principal {
    grid-area: main;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    background: #e9ecef;
}

/* ============================================
   EL CARNET (DNI)
   ============================================ */
.dni-container {
    width: 900px; 
    height: 522px;
    background-image: url('assets/fondo_dni2.jpg');
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(74, 35, 90, 0.3);
    position: relative;
    overflow: hidden;
    font-family: Arial, Helvetica, sans-serif;
}

/* Posiciones Absolutas para calcar la imagen */
.campo-dni {
    position: absolute;
    display: flex;
    flex-direction: column;
}

.valor-dni {
    font-size: 1.1rem;
    font-weight: 700;
    color: #000;
    background: rgba(255, 255, 255, 0.75);
    padding: 0.05rem 0.6rem;
    border-radius: 4px;
    display: inline-block;
    width: fit-content;
    min-width: 120px;
    line-height: 1;
}

/* Posiciones específicas */
.campo-nombre   { top: 26.5%; left: 30%; }
.campo-apellido { top: 47%; left: 30%; }
.campo-estado   { top: 65%; left: 30%; }
.campo-genero   { top: 84%; left: 30%; }

/* Foto */
.campo-foto {
    position: absolute;
    top: 26%; 
    right: 13.5%; 
    width: 22%;
    height: 52%;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(45%, -10%); 
}

.campo-foto img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    filter: grayscale(100%) opacity(0.85) blur(0.4px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    background: transparent;
    transition: opacity 0.3s ease, filter 0.3s ease, visibility 0.3s ease;
}

.campo-foto:hover img {
    opacity: 1;
    filter: grayscale(100%) blur(0);
}

.campo-foto img.oculto {
    opacity: 0;
    visibility: hidden;
}

/* Botón Generar PDF */
.btn-generar {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50px;
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(155, 89, 182, 0.3);
    transition: transform 0.2s, background 0.2s;
}
.btn-generar:hover { background: var(--accent-hover); transform: translateY(-2px); }
.btn-generar:disabled { background: #999; cursor: not-allowed; transform: none; box-shadow: none; }

/* ============================================
   RESPONSIVE
   ============================================ */

/* 1. Tablets y pantallas menores a 1024px */
@media (max-width: 1024px) {
    html, body { overflow: auto; }
    
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--cabecera-h) auto 1fr;
        grid-template-areas: "header" "menu" "main";
        height: auto;
        min-height: 100%;
    }

    .menu {
        border-right: none;
        border-bottom: 1px solid var(--border-soft);
        padding: 1rem;
    }

    #dniForm {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 1rem;
    }
    #dniForm .btn-generar { grid-column: 1 / -1; }

    .principal { padding: 1rem; min-height: 400px; }
}

/* 2. Móviles menores a 768px */
@media (max-width: 768px) {
    .cabecera { padding: 0 0.5rem; }
    .cabecera-titulo { font-size: 1rem; }
    
    /* ✅ Reducimos el padding del menú a la mitad (de 0.8rem a 0.4rem) */
    .menu { padding: 0.4rem; }
    
    #dniForm { grid-template-columns: 1fr; }

    /* ✅ Reducimos el padding del principal y el margen al mínimo */
    .principal { 
        padding: 1rem; /* ✅ Prueba con 1rem o 0.8rem para un punto medio */
        margin: 0;
        align-items: center; 
        min-height: auto; 
    }
    
    /* ✅ Devolvemos el tamaño original de la miniatura (max 400px) */
    .dni-container {
        width: 100%; 
        max-width: 400px; /* Tamaño original */
        height: auto;
        aspect-ratio: 900 / 522;
        border-radius: 8px; /* Bordes redondeados originales */
        margin: 0 auto; /* Centrado */
        box-shadow: 0 10px 30px rgba(74, 35, 90, 0.3); /* Sombra original */
    }

    .campo-dni { position: absolute; }
    .valor-dni {
        font-size: 0.65rem;
        padding: 0.1rem 0.3rem;
        min-width: 60px;
    }

    .campo-nombre   { top: 26.5%; left: 30%; }
    .campo-apellido { top: 47%; left: 30%; }
    .campo-estado   { top: 65%; left: 30%; }
    .campo-genero   { top: 84%; left: 30%; }
    
    .campo-foto {
        top: 26%;
        right: 13.5%;
        width: 22%;
        height: 52%;
        transform: translate(45%, -10%);
    }
}

@media (max-width: 400px) {
    .valor-dni {
        font-size: 0.55rem;
        padding: 0.1rem 0.2rem;
    }
}