/* ============================================================
   ESTILOS GLOBALES  — Sistema de Comisiones
   Mobile-first / POS táctil
   ============================================================ */

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

html { font-size: 16px; }

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #ecf0f1;
    color: #2c3e50;
    min-height: 100vh;
}

/* ============================================================
   HEADER / BARRA SUPERIOR
   ============================================================ */
.header {
    background: #1a252f;
    color: #fff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

.header-titulo {
    font-size: 1.1rem;
    font-weight: bold;
    letter-spacing: .5px;
}

.header-sub {
    font-size: .75rem;
    opacity: .7;
    margin-top: 2px;
}

.header-usuario {
    font-size: .8rem;
    text-align: right;
    opacity: .85;
}

.btn-header {
    background: rgba(255,255,255,.15);
    color: #fff;
    border: 1px solid rgba(255,255,255,.3);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: .85rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-header:active { background: rgba(255,255,255,.25); }

/* ============================================================
   CONTENEDOR PRINCIPAL
   ============================================================ */
.contenedor {
    padding: 16px;
    max-width: 700px;
    margin: 0 auto;
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 36px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo h1 {
    font-size: 1.5rem;
    color: #1a252f;
}

.login-logo p {
    font-size: .85rem;
    color: #7f8c8d;
    margin-top: 4px;
}

.form-grupo {
    margin-bottom: 18px;
}

.form-grupo label {
    display: block;
    font-size: .85rem;
    font-weight: bold;
    color: #555;
    margin-bottom: 6px;
}

.form-grupo input,
.form-grupo select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color .2s;
    appearance: none;
}

.form-grupo input:focus,
.form-grupo select:focus {
    outline: none;
    border-color: #2980b9;
}

/* ============================================================
   BOTONES GENERALES
   ============================================================ */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: opacity .15s, transform .1s;
}

.btn:active { transform: scale(.97); opacity: .9; }

.btn-primario  { background: #2980b9; color: #fff; }
.btn-exito     { background: #27ae60; color: #fff; }
.btn-peligro   { background: #e74c3c; color: #fff; }
.btn-naranja   { background: #e67e22; color: #fff; }
.btn-gris      { background: #95a5a6; color: #fff; }
.btn-oscuro    { background: #2c3e50; color: #fff; }
.btn-secundario {
    background: #fff;
    color: #2c3e50;
    border: 2px solid #bdc3c7;
}

.btn-sm {
    padding: 8px 16px;
    font-size: .85rem;
    width: auto;
    display: inline-block;
}

/* ============================================================
   BOTONES POS  (táctiles grandes)
   ============================================================ */
.grid-pos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.grid-pos-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 500px) {
    .grid-pos   { grid-template-columns: repeat(3, 1fr); }
    .grid-pos-3 { grid-template-columns: repeat(4, 1fr); }
}

.btn-pos {
    min-height: 100px;
    border: none;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px;
    text-align: center;
    line-height: 1.3;
    transition: transform .1s, box-shadow .1s;
    position: relative;
    box-shadow: 0 3px 6px rgba(0,0,0,.2);
    text-decoration: none;
}

.btn-pos:active {
    transform: scale(.94);
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

/* Colores POS */
.pos-verde   { background: #27ae60; color: #fff; }
.pos-rojo    { background: #e74c3c; color: #fff; }
.pos-azul    { background: #2980b9; color: #fff; }
.pos-naranja { background: #e67e22; color: #fff; }
.pos-morado  { background: #8e44ad; color: #fff; }
.pos-gris    { background: #7f8c8d; color: #fff; }

.btn-pos .pos-icono {
    font-size: 2rem;
    line-height: 1;
}

.btn-pos .pos-label {
    font-size: .9rem;
}

.btn-pos .pos-precio {
    font-size: .8rem;
    opacity: .85;
}

/* Badge de cantidad sobre botón */
.badge-cantidad {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #f39c12;
    color: #fff;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: .8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================
   ALERTAS / MENSAJES
   ============================================================ */
.alerta {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: .9rem;
    font-weight: bold;
}

.alerta-error   { background: #fdecea; color: #c0392b; border-left: 4px solid #e74c3c; }
.alerta-exito   { background: #eafaf1; color: #1e8449; border-left: 4px solid #27ae60; }
.alerta-info    { background: #eaf4fb; color: #1a5276; border-left: 4px solid #2980b9; }
.alerta-warning { background: #fef9e7; color: #9a7d0a; border-left: 4px solid #f39c12; }

/* ============================================================
   TABLA CARRITO / REPORTES
   ============================================================ */
.tabla-wrap {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: .9rem;
}

thead th {
    background: #2c3e50;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    font-size: .85rem;
}

tbody tr:nth-child(even) { background: #f8f9fa; }
tbody tr:hover           { background: #eaf4fb; }

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #ecf0f1;
    vertical-align: middle;
}

.td-centro { text-align: center; }
.td-derecha { text-align: right; }

/* Fila de subtotal dentro de tabla */
tr.fila-total td {
    background: #eaf4fb;
    font-weight: bold;
    border-top: 2px solid #2980b9;
}

/* Fila agrupadora (doctor) */
tr.fila-doctor td {
    background: #2c3e50;
    color: #fff;
    font-weight: bold;
    font-size: .95rem;
}

/* ============================================================
   SECCIÓN CARRITO (selección de medicamentos)
   ============================================================ */
.carrito-seccion {
    margin: 0 16px 16px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    overflow: hidden;
}

.carrito-header {
    background: #2c3e50;
    color: #fff;
    padding: 10px 16px;
    font-weight: bold;
    font-size: .95rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.carrito-total {
    background: #27ae60;
    color: #fff;
    padding: 12px 16px;
    font-size: 1.1rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
}

.btn-eliminar-item {
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: .85rem;
    cursor: pointer;
    font-weight: bold;
}

/* Botones +/- de cantidad dentro del carrito */
.btn-cantidad {
    background: #2c3e50;
    color: #fff;
    border: none;
    border-radius: 5px;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-cantidad:active { background: #1a252f; }

/* ============================================================
   FORMULARIOS ADMIN
   ============================================================ */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    padding: 20px;
    margin-bottom: 16px;
}

.card-titulo {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #ecf0f1;
}

.fila-form {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.fila-form .form-grupo {
    flex: 1;
    min-width: 140px;
    margin-bottom: 0;
}

/* ============================================================
   ETIQUETAS DE ESTADO
   ============================================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: bold;
}

.badge-activo   { background: #d5f5e3; color: #1e8449; }
.badge-inactivo { background: #fadbd8; color: #922b21; }
.badge-admin    { background: #d6eaf8; color: #1a5276; }
.badge-usuario  { background: #f2f3f4; color: #555; }

/* ============================================================
   DIVISOR / ESPACIADO
   ============================================================ */
.mt-1 { margin-top: 8px;  }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px;  }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.separador {
    border: none;
    border-top: 1px solid #ddd;
    margin: 16px 0;
}

/* ============================================================
   SECCIÓN FILTROS (reporte)
   ============================================================ */
.filtros-card {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,.1);
}

.filtros-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (min-width: 500px) {
    .filtros-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============================================================
   PASO INDICATOR (agregar registro)
   ============================================================ */
.pasos {
    display: flex;
    padding: 12px 16px;
    gap: 8px;
}

.paso-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    border-radius: 6px;
    font-size: .8rem;
    font-weight: bold;
    background: #dfe6e9;
    color: #7f8c8d;
}

.paso-item.activo {
    background: #2980b9;
    color: #fff;
}

.paso-item.completo {
    background: #27ae60;
    color: #fff;
}

/* ============================================================
   INFO DOCTOR SELECCIONADO (paso 2)
   ============================================================ */
.info-doctor {
    background: #2c3e50;
    color: #fff;
    padding: 10px 16px;
    font-size: .9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================================
   BOTÓN GUARDAR FIJO AL FONDO
   ============================================================ */
.barra-guardar {
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 12px 16px;
    box-shadow: 0 -3px 10px rgba(0,0,0,.15);
    z-index: 50;
}
