/* Estilos personalizados para el Sistema de Seguros */

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    min-height: 100vh;
}

/* Estilos para el Login */
.card {
    border: none;
    border-radius: 15px;
}

.card-body {
    border-radius: 15px;
}

.btn-primary {
    background-color: #0d6efd;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Estilos para resultados de búsqueda */
.resultado-no-apto {
    background-color: #f8d7da;
    border: 2px solid #dc3545;
    border-radius: 10px;
    padding: 30px;
    animation: shake 0.5s;
}

.resultado-apto {
    background-color: #d1e7dd;
    border: 2px solid #198754;
    border-radius: 10px;
    padding: 20px;
    animation: fadeIn 0.5s;
}

.alerta-no-apto {
    background-color: #dc3545;
    color: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(220, 53, 69, 0.3);
}

.info-asegurado {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.info-item {
    margin-bottom: 10px;
}

.info-item strong {
    display: inline-block;
    width: 120px;
    color: #495057;
}

/* Estilos para lista de especialidades */
.especialidades-container {
    background-color: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.especialidad-item {
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: #e7f1ff;
    border-left: 4px solid #0d6efd;
    border-radius: 5px;
    transition: all 0.3s ease;
}

.especialidad-item:hover {
    background-color: #cfe2ff;
    transform: translateX(5px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Badge para cantidad de especialidades */
.badge-especialidades {
    font-size: 1rem;
    padding: 8px 15px;
}

/* Animaciones */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Estilos para el navbar */
.navbar-brand img {
    filter: brightness(0) invert(1);
}

/* Estilos responsivos */
@media (max-width: 768px) {
    .info-item strong {
        display: block;
        width: 100%;
        margin-bottom: 5px;
    }

    .alerta-no-apto {
        font-size: 1.2rem;
        padding: 15px;
    }
}

/* Estado badges */
.badge-activo {
    background-color: #198754;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

.badge-inactivo {
    background-color: #dc3545;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.9rem;
}

/* Icono de búsqueda */
.bi-search {
    font-size: 1.2rem;
}

/* Loading spinner */
#loadingSpinner {
    padding: 40px 0;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Estilos para especialidades con radio buttons */
.especialidad-item-radio {
    padding: 12px 15px;
    margin-bottom: 8px;
    background-color: #e7f1ff;
    border: 2px solid transparent;
    border-radius: 5px;
    transition: all 0.3s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
}

.especialidad-item-radio:hover {
    background-color: #cfe2ff;
    border-color: #0d6efd;
    transform: translateX(3px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.especialidad-item-radio input[type="radio"] {
    cursor: pointer;
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

.especialidad-item-radio input[type="radio"]:checked + label {
    font-weight: bold;
    color: #0d6efd;
}

.especialidad-item-radio input[type="radio"]:checked ~ label {
    font-weight: bold;
}

.especialidad-item-radio label {
    cursor: pointer;
    margin: 0;
    flex: 1;
    user-select: none;
}

/* Destacar especialidad seleccionada */
.especialidad-item-radio:has(input[type="radio"]:checked) {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
    font-weight: bold;
}

.especialidad-item-radio:has(input[type="radio"]:checked) label {
    color: white;
}

/* Estilos para el ticket de impresión */
.ticket-container {
    font-family: 'Courier New', Courier, monospace;
    width: 80ch;
    max-width: 100%;
    background: white;
    color: black;
    padding: 20px;
    margin: 0 auto;
    font-size: 11pt;
    line-height: 1.4;
}

.ticket-section {
    margin-bottom: 10px;
}

.ticket-header {
    text-align: center;
    font-weight: normal;
    letter-spacing: 0;
}

.ticket-empresa {
    text-align: center;
    font-weight: bold;
    font-size: 13pt;
    margin: 5px 0;
    letter-spacing: 1px;
}

.ticket-titulo-grande {
    text-align: center;
    font-weight: bold;
    font-size: 13pt;
    margin: 5px 0;
    letter-spacing: 1px;
}

.ticket-titulo {
    text-align: center;
    font-weight: bold;
    font-size: 11pt;
    margin: 5px 0;
}

.ticket-subtitulo {
    text-align: center;
    font-weight: normal;
}

.ticket-fecha-hora {
    font-size: 10pt;
    margin: 10px 0;
}

.ticket-datos {
    margin: 15px 0;
    line-height: 1.6;
}

.ticket-datos div {
    margin-bottom: 5px;
}

.ticket-label {
    display: inline-block;
    font-weight: normal;
    min-width: 12ch;
}

.ticket-especialidad {
    margin: 20px 0;
    font-size: 11pt;
}

.ticket-especialidad strong {
    font-weight: bold;
}

.ticket-firma {
    text-align: center;
    margin-top: 30px;
    margin-bottom: 20px;
}

.ticket-linea-firma {
    margin-top: 30px;
    text-align: center;
}

.ticket-footer {
    text-align: center;
    font-size: 9pt;
    line-height: 1.5;
    margin-top: 15px;
}

.ticket-footer div {
    margin-bottom: 3px;
}

/* Ocultar comprobantes en pantalla */
#autorizacion, #ticketImpresion { display: none; }

/* ── Estilos del comprobante A4 (visibles en pantalla dentro del div, pero div oculto) ── */
.auth-table { width: 100%; border-collapse: collapse; }
.auth-table th, .auth-table td { border: 1px solid #000; padding: 1mm 2mm; font-size: 9pt; }
.auth-notas { font-size: 7.5pt; margin: 2mm 0; }
.auth-footer { text-align: center; font-size: 8pt; margin-top: 3mm; }
.auth-header-table { width: 100%; border-collapse: collapse; margin-bottom: 2mm; }
.auth-datos-table { width: 100%; border-collapse: collapse; margin-bottom: 2mm; font-size: 9pt; }
.auth-datos-table td { padding: 0.5mm 1mm; }
.auth-separator { border: none; border-top: 1px solid #000; margin: 2mm 0; }

/* ── Impresión dual-mode ─────────────────────────────────────────────────── */
@media print {
    /* Ocultar toda la UI */
    body > *:not(#autorizacion):not(#ticketImpresion) { display: none !important; }

    /* ── MODO A4 ──────────────────────────────────────────────────────────── */
    body.print-a4 #autorizacion {
        display: block !important;
        font-family: Arial, sans-serif;
        font-size: 9pt;
        color: #000;
        background: #fff;
    }
    body.print-a4 #ticketImpresion { display: none !important; }

    /* ── MODO TICKET (matricial texto plano) ─────────────────────────────── */
    body.print-ticket #ticketImpresion {
        display: block !important;
        font-family: 'Courier New', Courier, monospace;
        font-size: 10pt;
        white-space: pre;
        color: #000;
        background: #fff;
        width: 80ch;
    }
    body.print-ticket #autorizacion { display: none !important; }

    /* Página A4 */
    body.print-a4 {
        background: #fff;
    }
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    /* Página ticket: sin márgenes */
    body.print-ticket {
        background: #fff;
    }
}

/* ══════════════════════════════════════════════════════════════════
   DARK MODE — overrides para la UI de visaciones
   ══════════════════════════════════════════════════════════════════ */

/* Página */
html.dark-mode body { background-color: #121212 !important; color: #ccc; }

/* Card principal */
html.dark-mode .card { background-color: #1c1c1c; border-color: #2d2d2d; }
html.dark-mode .card-body { background-color: #1c1c1c; color: #ccc; }
html.dark-mode .card-header.bg-primary { background-color: #1a5fa0 !important; }

/* Resultado APTO — verde oscuro en lugar de verde claro */
html.dark-mode .resultado-apto {
    background-color: #0d2b1e;
    border-color: #198754;
    color: #aee8c2;
}

/* Resultado NO APTO — rojo oscuro */
html.dark-mode .resultado-no-apto {
    background-color: #2b0d0d;
    border-color: #dc3545;
    color: #f5b8be;
}

/* Info del asegurado (caja blanca interna) */
html.dark-mode .info-asegurado {
    background-color: #252525;
    box-shadow: 0 2px 4px rgba(0,0,0,.4);
    color: #ddd;
}
html.dark-mode .info-item strong { color: #9ab !important; }

/* Alert dentro de resultado (apto/no-apto) */
html.dark-mode .resultado-apto .alert-success {
    background-color: #0d2e1a;
    border-color: #198754;
    color: #aee8c2;
}
html.dark-mode .resultado-apto .alert-warning {
    background-color: #2b2100;
    border-color: #ffc107;
    color: #ffe08a;
}

/* Badge ACTIVO */
html.dark-mode .badge-activo { background-color: #145a32; color: #aee8c2; }

/* Select de servicios */
html.dark-mode .form-select {
    background-color: #2a2a2a;
    border-color: #444;
    color: #ddd;
}
html.dark-mode .form-select:focus {
    background-color: #2a2a2a;
    border-color: #2ea3f2;
    color: #ddd;
}
html.dark-mode .form-select option { background-color: #2a2a2a; color: #ddd; }

/* Inputs */
html.dark-mode .form-control {
    background-color: #2a2a2a;
    border-color: #444;
    color: #ddd;
}
html.dark-mode .form-control:focus {
    background-color: #2a2a2a;
    border-color: #2ea3f2;
    color: #ddd;
    box-shadow: 0 0 0 .2rem rgba(46,163,242,.25);
}
html.dark-mode .form-control::placeholder { color: #666; }

/* Labels */
html.dark-mode .form-label { color: #bbb; }
html.dark-mode small.text-muted { color: #777 !important; }

/* btn-group toggle carnet/CI */
html.dark-mode .btn-outline-primary {
    color: #5ab8f8;
    border-color: #5ab8f8;
}
html.dark-mode .btn-outline-primary:hover {
    background-color: #1a5fa0;
    color: #fff;
    border-color: #5ab8f8;
}
html.dark-mode .btn-check:checked + .btn-outline-primary {
    background-color: #1a5fa0;
    color: #fff;
    border-color: #2ea3f2;
}

/* Card confirmación visación */
html.dark-mode .card.border-success { border-color: #198754 !important; }
html.dark-mode .card.border-success .card-header.bg-success { background-color: #145a32 !important; }
html.dark-mode .card.border-success .card-body { background-color: #1a1a1a; color: #ccc; }
html.dark-mode .card.border-success .card-footer { background-color: #151515; border-color: #2d2d2d; }

/* dl row en confirmación */
html.dark-mode dt { color: #9ab; }
html.dark-mode dd { color: #ddd; }

/* btn-outline-secondary en footer confirmación */
html.dark-mode .btn-outline-secondary {
    color: #9ab;
    border-color: #555;
}
html.dark-mode .btn-outline-secondary:hover {
    background-color: #333;
    color: #fff;
    border-color: #777;
}

/* Spinner */
html.dark-mode #loadingSpinner p { color: #9ab; }

/* ═══════════════════════════════════════════════════════════════= */

/* Estilos para el botón de generar ticket */
#btnGenerarTicket {
    transition: all 0.3s ease;
    font-size: 1.1rem;
    padding: 12px 30px;
}

#btnGenerarTicket:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#btnGenerarTicket:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ═══════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — resultados de visado + consulta
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Sidebar ya maneja su propia responsive */

    /* Formulario buscar: stack vertical */
    #formBuscarCarnet .row { flex-direction: column; }
    #formBuscarCarnet .col-md-9,
    #formBuscarCarnet .col-md-3 { width: 100%; }
    #formBuscarCarnet .btn { margin-top: 8px; }

    /* Resultado apto: campos stack vertical */
    .resultado-apto .row { flex-direction: column; }
    .resultado-apto .row > [class*="col-"] { width: 100% !important; margin-bottom: 6px; }

    /* Input group stack si es ancho (pais+celular, servicio+btn) */
    .resultado-apto .input-group { flex-wrap: wrap; }
    .resultado-apto .input-group > .form-control,
    .resultado-apto .input-group > .form-select { min-width: 100% !important; max-width: 100% !important; }
    .resultado-apto .input-group > .btn { width: 100%; margin-top: 4px; border-radius: 6px !important; }
    .resultado-apto .input-group > select#inputPais { max-width: 100% !important; }

    /* Botón generar: full width en mobile ya es d-grid */

    /* Servicio select: font menor */
    #servicioSelect { font-size: .9rem !important; }

    /* Cards de resultado: padding reducido */
    .resultado-apto,
    .resultado-no-apto { padding: 14px !important; }

    /* Tablas: horizontal scroll si es necesario */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Mini modal: full width en mobile */
    .modal-dialog { margin: 10px; max-width: calc(100% - 20px); }

    /* Comprobante A4 hidden en mobile (solo ticket) */
    /* Badge activo: más grande en mobile para legibilidad */
    .badge-activo,
    .badge-inactivo { font-size: 1rem; padding: 8px 14px; }

    /* Prestadores tabla: wrap acciones */
    #tablaPrestadores td:last-child { flex-wrap: wrap; }

    /* Tipografia general mobile */
    h4, h5 { font-size: 1.1rem; }
    .card-header h4 { font-size: 1rem; }

    /* Visar container: menos margin top */
    .container.mt-5 { margin-top: 1rem !important; }
    .container.mt-4 { margin-top: .5rem !important; }
}

@media (max-width: 480px) {
    /* Extra small: botón toggle busqueda stack */
    #tipoBusquedaGrp { flex-direction: column; }
    #tipoBusquedaGrp .btn { border-radius: 6px !important; margin-bottom: 4px; }

    /* Resultado: nombre grande, datos abajo */
    .resultado-apto h5,
    .resultado-no-apto h5 { font-size: 1rem; }

    .form-control-lg { font-size: 1rem; padding: 8px 12px; }
    .btn-lg { font-size: .95rem; padding: 10px 18px; }
}

/* ── Admin — pages mobile ─────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Modales admin: full width con margen minimo */
    .modal-dialog { margin: .5rem !important; max-width: calc(100% - 1rem) !important; }
    .modal-dialog-scrollable { max-height: calc(100vh - 1rem); }
    .modal-content { max-height: calc(100vh - 1rem); }

    /* Filtros de top page: stack */
    .d-flex.flex-wrap { gap: .5rem !important; }
    .input-group { flex-wrap: wrap; }
    .btn-group { flex-wrap: wrap; }

    /* Tablas admin con muchas columnas: scroll horizontal + texto menor */
    .table-sm { font-size: .78rem; }
    .table-sm td, .table-sm th { padding: .3rem .4rem; }

    /* Cards con gap reducido */
    .card-body { padding: .8rem; }
    .card-header { padding: .5rem .8rem; }
    .card-header h2, .card-header h3, .card-header h4, .card-header h5 { font-size: 1rem; }

    /* Info modal anular */
    #modalAnular textarea { font-size: .9rem; }

    /* Paginación smaller */
    .page-link { padding: .25rem .5rem; font-size: .8rem; }

    /* Prestador medicos: acciones stack */
    [data-svc-med], [data-toggle-med] { margin-top: .25rem; }

    /* Servicios tabla: nombre wrap */
    #tablaServicios td { word-break: break-word; }

    /* Rol cards creacion user: 1 col en muy pequeño */
    .card-rol { padding: 1rem .5rem !important; }
    .card-rol h6 { font-size: .85rem; }
    .card-rol small { font-size: .7rem; }
    .card-rol .fs-1 { font-size: 1.8rem !important; }
}

/* ── Dias control input tamaño ───────────────────────────────────── */
@media (max-width: 480px) {
    .dias-ctrl-input { width: 60px !important; font-size: .75rem; }
    .card-rol .fs-1 { font-size: 1.5rem !important; }
}
