/* ========================================
   VARIABLES Y CONFIGURACIÓN GLOBAL
======================================== */
:root {
    /* Colores principales */
    --color-primario: #116937;
    --color-primario-hover: #0d522b;
    --color-secundario: #27ae60;
    --color-acento: #e67e22;
    --color-whatsapp: #25D366;

    /* Colores de fondo */
    --bg-principal: #f0f4f8;
    --bg-card: #ffffff;
    --bg-input: #f9fafb;

    /* Colores de texto */
    --texto-principal: #1f2937;
    --texto-secundario: #4b5563;
    --texto-claro: #9ca3af;

    /* Sombras */
    --sombra-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --sombra-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --sombra-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --sombra-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);

    /* Bordes */
    --radio-sm: 8px;
    --radio-md: 12px;
    --radio-lg: 16px;

    /* Fuente */
    --fuente-principal: 'Outfit', sans-serif;
}

body.dark-mode {
    --bg-principal: #111827;
    --bg-card: #1f2937;
    --bg-input: #374151;
    --texto-principal: #f3f4f6;
    --texto-secundario: #d1d5db;
    --color-primario: #2ecc71;
}

/* ========================================
   ESTILOS GENERALES
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--fuente-principal);
    background-color: var(--bg-principal);
    color: var(--texto-principal);
    line-height: 1.6;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1rem 0;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.logo-container i {
    font-size: 2.2rem;
    color: var(--color-primario);
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
}

.header-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid #ddd;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
}

.btn-install {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: var(--radio-md);
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    font-family: var(--fuente-principal);
}

.btn-install:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-install i {
    font-size: 1rem;
}

.select-plantilla {
    padding: 10px 20px;
    border-radius: 20px;
    border: 1px solid #ddd;
    background: var(--bg-card);
    color: var(--texto-principal);
}

/* ========================================
   LAYOUT PRINCIPAL
======================================== */
main {
    max-width: 1280px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media (min-width: 1024px) {
    main {
        grid-template-columns: 450px 1fr;
    }
}

.card {
    background: var(--bg-card);
    padding: 2rem;
    border-radius: var(--radio-lg);
    box-shadow: var(--sombra-md);
}

/* ========================================
   FORMULARIO
======================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e7eb;
    border-radius: var(--radio-sm);
    background: var(--bg-input);
    color: var(--texto-principal);
    font-family: inherit;
    font-size: 0.95rem;
}

.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group select {
    width: auto;
    min-width: 120px;
}

/* ========================================
   UPLOAD FOTOS
======================================== */
.photo-upload-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.photo-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    border: 2px dashed #d1d5db;
    border-radius: var(--radio-md);
    cursor: pointer;
    background: var(--bg-input);
    min-height: 100px;
    text-align: center;
}

.photo-label:hover {
    border-color: var(--color-primario);
    color: var(--color-primario);
}

.photo-upload-item input {
    display: none;
}

.preview-thumb {
    margin-top: 8px;
    border-radius: var(--radio-sm);
    overflow: hidden;
    height: 80px;
    display: none;
}

.preview-thumb.active {
    display: block;
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ========================================
   BOTONES
======================================== */
.btn-primario,
.btn-export,
.btn-whatsapp,
.btn-secundario {
    padding: 14px 20px;
    border: none;
    border-radius: var(--radio-md);
    font-weight: 600;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: var(--fuente-principal);
    transition: transform 0.2s;
}

.btn-primario {
    background: #116937;
    width: 100%;
}

.btn-secundario-outline {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 2px solid #ddd;
    border-radius: var(--radio-md);
    cursor: pointer;
    color: var(--texto-principal);
    font-weight: 600;
}

.btn-export {
    background: #e67e22;
}

.btn-whatsapp {
    background: #25D366;
}

.form-actions {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 10px;
    margin-top: 2rem;
}

.acciones {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 2rem;
}

/* ========================================
   VISTA PREVIA DE LA FICHA (DISEÑO A4)
   Dimensiones exactas para A4 a 96dpi: 794px x 1123px
======================================== */
.ficha-container {
    background: white;
    width: 794px;
    height: 1123px;
    margin: 0 auto 30px auto;
    box-shadow: var(--sombra-xl);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
}

/* HEADER Y LOGO */
.ficha-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    pointer-events: none;
    padding-top: 25px;
}

.ficha-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.ficha-logo img {
    max-width: 220px;
    max-height: 110px;
    object-fit: contain;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 10px;
}

.ficha-badge {
    position: absolute;
    top: 30px;
    right: 30px;
    background: var(--color-primario);
    color: white;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: var(--sombra-md);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* GALERÍA DINÁMICA DE FOTOS */
.ficha-galeria {
    width: 100%;
    height: 550px;
    display: grid;
    gap: 4px;
    background: #f0f0f0;
}

/* Layouts dinámicos */
.ficha-galeria.layout-1 {
    grid-template-columns: 1fr;
}

.ficha-galeria.layout-2 {
    grid-template-columns: 1fr 1fr;
}

.ficha-galeria.layout-3 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.ficha-galeria.layout-3 .foto-item:nth-child(1) {
    grid-row: 1 / -1;
    grid-column: 1 / 2;
}

.ficha-galeria.layout-4 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
}

.ficha-galeria.layout-4 .foto-item:nth-child(1) {
    grid-row: 1 / -1;
    grid-column: 1 / 2;
}

/* Estilos de items de foto */
.foto-item {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: #ddd;
}

.foto-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.foto-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #e5e5e5;
    color: #888;
}

/* INFORMACIÓN */
.ficha-info {
    padding: 30px 40px;
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: white;
}

.ficha-encabezado {
    margin-bottom: 25px;
    border-bottom: 2px solid var(--color-primario);
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.titulo-block {
    max-width: 70%;
}

.ficha-titulo {
    font-size: 24px;
    font-weight: 700;
    color: #111;
    margin-bottom: 5px;
    line-height: 1.2;
}

.ficha-direccion {
    font-size: 14px;
    color: #555;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ficha-precio-large {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-primario);
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.tipo-operacion {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #666;
    background: #f0f0f0;
    padding: 4px 12px;
    border-radius: 4px;
}

/* CARACTERÍSTICAS (GRID MEJORADO) */
.ficha-specs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.spec-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.spec-item i {
    font-size: 1.4rem;
    color: var(--color-primario);
    width: 24px;
    text-align: center;
}

.spec-item div {
    display: flex;
    flex-direction: column;
}

.spec-item strong {
    font-size: 1.1rem;
    color: #333;
}

.spec-item span {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #777;
    letter-spacing: 0.5px;
}

/* DESCRIPCIÓN */
.ficha-descripcion {
    margin-bottom: auto;
    font-size: 14px;
    color: #444;
    line-height: 1.6;
    text-align: justify;
    max-height: 200px;
    overflow: hidden;
}

.ficha-descripcion h4 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #111;
    font-weight: 600;
}

/* CONTACTO FOOTER */
.ficha-contacto {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #eee;
}

.agente-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.agente-info i {
    font-size: 2rem;
    color: var(--color-primario);
}

.btn-whatsapp-ficha {
    background: #25D366;
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    text-decoration: none;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    box-shadow: 0 4px 10px rgba(37, 211, 102, 0.3);
}

/* ========================================
   PLANTILLAS - VARIANTES DE ESTILO
======================================== */

/* PLANTILLA MODERNA - Oscura y Bold */
.ficha-container.moderna {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.ficha-container.moderna .ficha-info {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
}

.ficha-container.moderna .ficha-titulo {
    color: #ffffff;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ficha-container.moderna .ficha-direccion {
    color: #aaa;
}

.ficha-container.moderna .ficha-precio-large {
    background: linear-gradient(90deg, #00D9FF, #00A8CC);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.ficha-container.moderna .ficha-encabezado {
    border-bottom: 2px solid #00D9FF;
}

.ficha-container.moderna .ficha-specs {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ficha-container.moderna .spec-item strong {
    color: #fff;
}

.ficha-container.moderna .spec-item span {
    color: #999;
}

.ficha-container.moderna .spec-item i {
    color: #00D9FF;
}

.ficha-container.moderna .ficha-descripcion {
    color: #ccc;
}

.ficha-container.moderna .ficha-descripcion h4 {
    color: #fff;
}

.ficha-container.moderna .ficha-contacto {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ficha-container.moderna .agente-info strong,
.ficha-container.moderna .agente-info p {
    color: #fff;
}

.ficha-container.moderna .ficha-badge {
    background: linear-gradient(90deg, #00D9FF, #00A8CC);
}

.ficha-container.moderna .tipo-operacion {
    background: rgba(0, 217, 255, 0.15);
    color: #00D9FF;
    border: 1px solid rgba(0, 217, 255, 0.3);
}

/* PLANTILLA ELEGANTE - Crema y Dorado */
.ficha-container.elegante {
    background: #fef8f0;
}

.ficha-container.elegante .ficha-info {
    background: #fef8f0;
}

.ficha-container.elegante .ficha-titulo {
    font-family: 'Georgia', serif;
    color: #5a4a3a;
    font-weight: 600;
}

.ficha-container.elegante .ficha-direccion {
    color: #8b7355;
}

.ficha-container.elegante .ficha-precio-large {
    color: #c9a961;
    font-family: 'Georgia', serif;
}

.ficha-container.elegante .ficha-encabezado {
    border-bottom: 2px solid #c9a961;
}

.ficha-container.elegante .ficha-specs {
    background: #fff;
    border: 2px solid #e8d7b8;
}

.ficha-container.elegante .spec-item i {
    color: #c9a961;
}

.ficha-container.elegante .spec-item strong {
    color: #5a4a3a;
}

.ficha-container.elegante .ficha-descripcion {
    color: #6b5b4b;
    font-family: 'Georgia', serif;
}

.ficha-container.elegante .ficha-descripcion h4 {
    color: #5a4a3a;
}

.ficha-container.elegante .ficha-contacto {
    background: #fff;
    border: 2px solid #e8d7b8;
}

.ficha-container.elegante .ficha-badge {
    background: #c9a961;
}

.ficha-container.elegante .tipo-operacion {
    background: #fff;
    color: #c9a961;
    border: 2px solid #e8d7b8;
}

/* PLANTILLA MINIMALISTA - Blanco Puro */
.ficha-container.minimalista {
    background: #ffffff;
}

.ficha-container.minimalista .ficha-info {
    background: #ffffff;
}

.ficha-container.minimalista .ficha-titulo {
    font-weight: 300;
    font-size: 28px;
    color: #000;
    letter-spacing: 2px;
}

.ficha-container.minimalista .ficha-direccion {
    color: #666;
    font-weight: 300;
}

.ficha-container.minimalista .ficha-precio-large {
    color: #000;
    font-weight: 300;
    font-size: 32px;
}

.ficha-container.minimalista .ficha-encabezado {
    border-bottom: 1px solid #000;
}

.ficha-container.minimalista .ficha-specs {
    background: transparent;
    border: 1px solid #e0e0e0;
}

.ficha-container.minimalista .spec-item i {
    color: #000;
}

.ficha-container.minimalista .spec-item strong {
    color: #000;
    font-weight: 400;
}

.ficha-container.minimalista .spec-item span {
    color: #999;
}

.ficha-container.minimalista .ficha-descripcion {
    color: #555;
    font-weight: 300;
}

.ficha-container.minimalista .ficha-descripcion h4 {
    color: #000;
    font-weight: 400;
}

.ficha-container.minimalista .ficha-contacto {
    background: #fafafa;
    border: 1px solid #e0e0e0;
}

.ficha-container.minimalista .ficha-badge {
    background: #000;
}

.ficha-container.minimalista .tipo-operacion {
    background: transparent;
    color: #000;
    border: 1px solid #e0e0e0;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .ficha-container {
        width: 100%;
        height: auto;
        min-height: 1123px;
    }

    .ficha-titulo {
        font-size: 1.5rem;
        margin-right: 0;
    }

    .ficha-precio-large {
        font-size: 22px;
    }

    .ficha-encabezado {
        flex-direction: column;
        align-items: flex-start;
    }

    .titulo-block {
        max-width: 100%;
    }

    .ficha-specs {
        grid-template-columns: repeat(2, 1fr);
    }

    .ficha-galeria {
        height: auto;
        min-height: 300px;
    }
}