/* =========================
   ESTILOS GENERALES
   ========================= */
body {
    font-family: Arial, sans-serif;
    background: #f4f6f8;
    margin: 0;
}

.container {
    padding: 15px;
}

/* =========================
   BARRA SUPERIOR
   ========================= */
.top-bar {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.top-bar input {
    width: 350px;
    padding: 8px;
    font-size: 14px;
}

/* =========================
   TABLA (PANTALLA)
   ========================= */
.tabla-container {
    max-height: 250px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ccc;
}

table {
    width: 100%;
    border-collapse: collapse;
}

/* ENCABEZADOS */
thead th {
    background: #1e88e5;
    color: #fff;
    padding: 10px;
    font-weight: 600;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 2;
}

/* CELDAS */
th,
td {
    padding: 8px;
    border-bottom: 1px solid #ddd;
    text-align: center;
}

tr.selected {
    background: #bbdefb;
}

/* =========================
   BOTONES
   ========================= */
.bottom-bar {
    margin: 10px 0;
    display: flex;
    gap: 10px;
}

.btn {
    padding: 8px 16px;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
}

.add    { background: #4caf50; color: #fff; }
.edit   { background: #ff9800; color: #fff; }
.delete { background: #f44336; color: #fff; }
.print  { background: #424242; color: #fff; }

/* =========================
   MODAL
   ========================= */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    width: 650px;
    max-width: 95%;
    border-radius: 6px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
}

.modal-header button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
}

/* =========================
   FORMULARIO
   ========================= */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.grid input,
.grid select {
    padding: 8px;
    font-size: 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.error-text {
    font-size: 12px;
    color: #d32f2f;
    display: none;
}

.input-error {
    border-color: #d32f2f !important;
    background: #fdecea;
}

/* =====================================================
   IMPRESIÓN – CONFIGURACIÓN GENERAL A4
   ===================================================== */
@page {
    size: A4;
    margin: 15mm;
}

@media print {

    body {
        background: #fff;
    }

    body * {
        visibility: hidden !important;
    }
}

/* =====================================================
   FICHA CLIENTE – IMPRESIÓN A4
   ===================================================== */
.ficha-cliente {
    display: none;
}

@media print {

    body.print-ficha .ficha-cliente,
    body.print-ficha .ficha-cliente * {
        visibility: visible !important;
    }

    body.print-ficha .ficha-cliente {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 210mm;
        min-height: 297mm;
        padding: 20mm;
        background: #fff;
        color: #000;
        font-size: 14px;
    }

    .ficha-header {
        display: flex;
        justify-content: space-between;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }

    .logo img {
        max-height: 80px;
    }

    .empresa {
        text-align: right;
        font-size: 13px;
    }

    .empresa h2 {
        margin: 0;
        font-size: 18px;
    }

    .titulo {
        text-align: center;
        font-size: 22px;
        margin: 25px 0;
        font-weight: bold;
    }

    .ficha-datos {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 14px 30px;
    }

    .ficha-datos div {
        border-bottom: 1px dotted #000;
        padding-bottom: 4px;
    }
}

/* =====================================================
   LISTADO CLIENTES – IMPRESIÓN A4 CONTABILIDAD / AFIP
   ===================================================== */
.listado-header-print {
    display: none;
}

@media print {

    body.print-listado .listado-header-print,
    body.print-listado .listado-header-print * {
        visibility: visible !important;
    }

    body.print-listado .listado-header-print {
        display: flex;
        gap: 20px;
        align-items: center;
        border-bottom: 2px solid #000;
        padding-bottom: 10px;
        margin-bottom: 15px;
    }

    .logo-print {
        max-height: 70px;
    }

    .empresa-print h2 {
        margin: 0;
        font-size: 18px;
    }

    body.print-listado .tabla-container,
    body.print-listado .tabla-container * {
        visibility: visible !important;
    }

    body.print-listado .tabla-container {
        position: relative;
        max-height: none;
        overflow: visible;
        border: none;
    }

    body.print-listado table {
        font-size: 11px;
        border-collapse: collapse;
        width: 100%;
    }

    body.print-listado th {
        background: #000 !important;
        color: #fff !important;
        padding: 6px;
    }

    body.print-listado td {
        border: 1px solid #000;
        padding: 5px;
    }

    /* NUMERACIÓN DE PÁGINAS */
    body.print-listado::after {
        content: "Página " counter(page);
        position: fixed;
        bottom: 10mm;
        right: 10mm;
        font-size: 11px;
    }
}
